You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
666 B
21 lines
666 B
2 years ago
|
package UnitTest;
|
||
|
|
||
|
public class test1 {
|
||
|
public static void main(String[] args) {
|
||
|
MultiThreadTool multiThreadTool = new MultiThreadTool(20);
|
||
|
|
||
|
for (int i = 0; i < 100; i++) {
|
||
|
int taskIndex = i;
|
||
|
multiThreadTool.execute(() -> {
|
||
|
System.out.println("Task " + taskIndex + " is running.");
|
||
|
try {
|
||
|
Thread.sleep(1000); // 模拟任务执行
|
||
|
} catch (InterruptedException e) {
|
||
|
e.printStackTrace();
|
||
|
}
|
||
|
System.out.println("Task " + taskIndex + " is completed.");
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
}
|