mirror of
https://github.com/LamGC/ContentGrabbingJi.git
synced 2025-07-05 14:57:25 +00:00
[Delete] PixivAccessProxyServer 移除弃用的类;
[Change] Locker 删除不必要的代码; [Change] PixivDownload 删除多余的Javadoc内容; [Change] TimeLimitThreadPoolExecutorTest 调整日志输出方向, 补充测试细节;
This commit is contained in:
@ -2,26 +2,37 @@ package net.lamgc.cgj.util;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class TimeLimitThreadPoolExecutorTest {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(TimeLimitThreadPoolExecutorTest.class);
|
||||
|
||||
@Test
|
||||
public void timeoutTest() throws InterruptedException {
|
||||
TimeLimitThreadPoolExecutor executor = new TimeLimitThreadPoolExecutor(1000, 1, 1, 30, TimeUnit.SECONDS, new ArrayBlockingQueue<>(50));
|
||||
System.out.println(executor.isTerminated());
|
||||
System.out.println(executor.isShutdown());
|
||||
log.info("ThreadPoolExecutor.isTerminated: {}", executor.isTerminated());
|
||||
log.info("ThreadPoolExecutor.isShutdown: {}", executor.isShutdown());
|
||||
|
||||
executor.setTimeoutCheckInterval(150);
|
||||
System.out.println("当前设定: ETL: " + executor.getExecuteTimeLimit() + "ms, TCI: " + executor.getTimeoutCheckInterval() + "ms");
|
||||
log.info("当前设定: ExecuteTimeLimit: {}ms, CheckInterval: {}ms", executor.getExecuteTimeLimit(),
|
||||
executor.getTimeoutCheckInterval());
|
||||
executor.execute(() -> {
|
||||
try {
|
||||
Thread.sleep(5 * 1000);
|
||||
Thread.sleep(5000);
|
||||
} catch (InterruptedException e) {
|
||||
System.out.println("线程 " + Thread.currentThread().getName() + " 被中断");
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
Assert.fail("Multiple interrupts occurred");
|
||||
}
|
||||
});
|
||||
executor.shutdown();
|
||||
Assert.assertTrue(executor.awaitTermination(5 * 1000, TimeUnit.MILLISECONDS));
|
||||
|
Reference in New Issue
Block a user