* fix -- 修改获取流程节点信息接口(供前端渲染流程跟踪图着色使用) * fix -- 修复流程跟踪着色问题 * fix -- 采用ProcessViewer组件显示流程跟踪信息 * fix -- 整合表单设计代码 * fix -- 简易实现用户任务选择用户下拉框内容 * fix -- 修改项目介绍及sql文件 * del -- 移除未使用的文件 * fix -- 修复组件无法显示和修改的问题 * add -- 整合 Rtony/RuoYi-flowable 工作流 * add -- 添加process-designer流程设计插件 * !3 同步ruoyi-vue-plus更新 * !2 登录认证用户信息添加nickName字段(流程任务需要使用到)
76 lines
2.1 KiB
Java
76 lines
2.1 KiB
Java
package com.ruoyi.common.utils;
|
|
|
|
import lombok.AccessLevel;
|
|
import lombok.NoArgsConstructor;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import java.util.concurrent.*;
|
|
|
|
/**
|
|
* 线程相关工具类.
|
|
*
|
|
* @author ruoyi
|
|
*/
|
|
@Slf4j
|
|
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
|
public class Threads {
|
|
|
|
/**
|
|
* sleep等待,单位为毫秒
|
|
*/
|
|
public static void sleep(long milliseconds) {
|
|
try {
|
|
Thread.sleep(milliseconds);
|
|
} catch (InterruptedException e) {
|
|
return;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 停止线程池
|
|
* 先使用shutdown, 停止接收新任务并尝试完成所有已存在任务.
|
|
* 如果超时, 则调用shutdownNow, 取消在workQueue中Pending的任务,并中断所有阻塞函数.
|
|
* 如果仍然超時,則強制退出.
|
|
* 另对在shutdown时线程本身被调用中断做了处理.
|
|
*/
|
|
public static void shutdownAndAwaitTermination(ExecutorService pool) {
|
|
if (pool != null && !pool.isShutdown()) {
|
|
pool.shutdown();
|
|
try {
|
|
if (!pool.awaitTermination(120, TimeUnit.SECONDS)) {
|
|
pool.shutdownNow();
|
|
if (!pool.awaitTermination(120, TimeUnit.SECONDS)) {
|
|
log.info("Pool did not terminate");
|
|
}
|
|
}
|
|
} catch (InterruptedException ie) {
|
|
pool.shutdownNow();
|
|
Thread.currentThread().interrupt();
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 打印线程异常信息
|
|
*/
|
|
public static void printException(Runnable r, Throwable t) {
|
|
if (t == null && r instanceof Future<?>) {
|
|
try {
|
|
Future<?> future = (Future<?>) r;
|
|
if (future.isDone()) {
|
|
future.get();
|
|
}
|
|
} catch (CancellationException ce) {
|
|
t = ce;
|
|
} catch (ExecutionException ee) {
|
|
t = ee.getCause();
|
|
} catch (InterruptedException ie) {
|
|
Thread.currentThread().interrupt();
|
|
}
|
|
}
|
|
if (t != null) {
|
|
log.error(t.getMessage(), t);
|
|
}
|
|
}
|
|
}
|