We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
所有版本
在客户端触发定时任务的动作里,见 JobThread 类;
if (triggerParam.getExecutorTimeout() > 0) { // limit timeout Thread futureThread = null; try { FutureTask<Boolean> futureTask = new FutureTask<Boolean>(new Callable<Boolean>() { @Override public Boolean call() throws Exception { // init job context XxlJobContext.setXxlJobContext(xxlJobContext); handler.execute(); return true; } }); futureThread = new Thread(futureTask); futureThread.start(); Boolean tempResult = futureTask.get(triggerParam.getExecutorTimeout(), TimeUnit.SECONDS); } //.....
采用了创建线程为载体,实现任务超时的回调函数;
因为需要考虑任务上下文 XxlJobContext ,父线程和子线程需要共享一个 ThreadLocal ,所以使用线程+InheritableThreadLocal 的组合(上述代码)可以理解; 不过目前存有大量任务,都设有超时时间,并且存在会同时频繁执行的情况; 这样一来以上代码对原本平稳运行的系统会带来不小的隐患。 所以未来是否会考虑使用线程池+TransmittableThreadLocal 的模式取代上述旧的执行逻辑 🤝
ThreadLocal
InheritableThreadLocal
TransmittableThreadLocal
The text was updated successfully, but these errors were encountered:
No branches or pull requests
版本
所有版本
问题
在客户端触发定时任务的动作里,见 JobThread 类;
采用了创建线程为载体,实现任务超时的回调函数;
疑问
因为需要考虑任务上下文 XxlJobContext ,父线程和子线程需要共享一个
ThreadLocal
,所以使用线程+InheritableThreadLocal
的组合(上述代码)可以理解;不过目前存有大量任务,都设有超时时间,并且存在会同时频繁执行的情况;
这样一来以上代码对原本平稳运行的系统会带来不小的隐患。
所以未来是否会考虑使用线程池+
TransmittableThreadLocal
的模式取代上述旧的执行逻辑 🤝The text was updated successfully, but these errors were encountered: