전체 글 (1) 썸네일형 리스트형 자바 타임아웃 거는법 import org.junit.Test; import java.util.concurrent.*; public class ExecutorTest { @Test(expected = TimeoutException.class) public void executorTest() throws Exception{ ExecutorService executor = Executors.newSingleThreadExecutor(); Callable task = new Callable() { public Object call() throws Exception { return sometimesTakeALongTime(); } }; Future future = executor.submit(task); future.get(300, .. 이전 1 다음