Java
자바 ExecutorService2
NaHyungMin
2020. 11. 3. 16:48
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");
}
}