提交 3b7bd399 编写于 作者: 武汉红喜's avatar 武汉红喜

concurrent test

上级 302a6987
...@@ -11,10 +11,10 @@ public class CompletionServiceTest { ...@@ -11,10 +11,10 @@ public class CompletionServiceTest {
public static void main(String[] args) { public static void main(String[] args) {
ExecutorService executor = Executors.newFixedThreadPool(10); ExecutorService executor = Executors.newFixedThreadPool(10);
CompletionService<Integer> completionService = new ExecutorCompletionService<>(executor); CompletionService<Integer> completionService = new ExecutorCompletionService<>(executor);
for (int i = 1; i <= 10; i++) { for (int i = 0; i < 10; i++) {
final int seq = i; final int seq = i + 1;
completionService.submit(() -> { completionService.submit(() -> {
Thread.sleep(new Random().nextInt(5000)); Thread.sleep(new Random().nextInt(3000));
return seq; return seq;
}); });
} }
......
...@@ -5,7 +5,7 @@ package org.hongxi.java.util.concurrent; ...@@ -5,7 +5,7 @@ package org.hongxi.java.util.concurrent;
* *
* @author shenhongxi * @author shenhongxi
* *
* @see InterruptTest2 * @see InterruptedTest
*/ */
public class InterruptTest { public class InterruptTest {
......
...@@ -5,7 +5,7 @@ package org.hongxi.java.util.concurrent; ...@@ -5,7 +5,7 @@ package org.hongxi.java.util.concurrent;
* *
* @author shenhongxi * @author shenhongxi
*/ */
public class InterruptTest2 { public class InterruptedTest {
public static void main(String[] args) { public static void main(String[] args) {
Thread t = new Thread(() -> { Thread t = new Thread(() -> {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册