package main.java.com;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
public class ExecutorServiceMain2 {
public static void main(String[] args) throws ExecutionException, InterruptedException {
System.out.println("start");
//쓰레드 픽스.
ExecutorService executorService = Executors.newFixedThreadPool(10);
Future<String> result = executorService.submit(() -> {
return "s";
});
System.out.println("end1");
//실행 완료 체크.
System.out.println( result.isDone());
String s = result.get();
System.out.println(s);
System.out.println( result.isDone());
System.out.println("end2");
}
}
'Java' 카테고리의 다른 글
자바 ExecutorService3(Callable) (0) | 2020.11.03 |
---|---|
자바 newCachedThreadPool , newFixedThreadPool (0) | 2020.11.03 |
자바 ExecutorService (0) | 2020.11.03 |
자바 쓰레드 Future (0) | 2020.11.03 |
스프링부트 JPA 사용기 (0) | 2020.11.01 |