mirror of
https://github.com/slhaf/Partner.git
synced 2026-05-12 16:53:04 +08:00
推进记忆模块
- 在 InteractionThreadPoolExecutor 中引入虚拟线程池 (newVirtualThreadPerTaskExecutor) - 更新相关测试文件以适应新的线程池 - 优化 MemorySummarizer 中的单条目摘要逻辑 - 为 SingleSummarizer 、 MultiSummarizer 设计了提示词 - 还差两份提示词没有设计...
This commit is contained in:
34
src/test/java/memory/ThreadPoolTest.java
Normal file
34
src/test/java/memory/ThreadPoolTest.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package memory;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class ThreadPoolTest {
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
testExecutor(Executors.newVirtualThreadPerTaskExecutor());
|
||||
|
||||
// Thread.sleep(2000); // 等待系统输出稳定
|
||||
|
||||
// testExecutor("普通线程池", Executors.newFixedThreadPool(100));
|
||||
}
|
||||
|
||||
private static void testExecutor(ExecutorService es) throws InterruptedException {
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
for (int i = 0; i < 100000; i++) {
|
||||
es.submit(() -> {
|
||||
Thread.sleep(1000);
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
es.shutdown();
|
||||
if (es.awaitTermination(5, TimeUnit.MINUTES)) {
|
||||
long end = System.currentTimeMillis();
|
||||
System.out.println("虚拟线程" + "耗时:" + (end - start));
|
||||
} else {
|
||||
System.err.println("虚拟线程" + "未能在规定时间内完成所有任务");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user