Calable接口的使用

public class call {code

public static void main(String[] args) throws InterruptedException, ExecutionException {

	ExecutorService service = Executors.newFixedThreadPool(1);
	
	Race r=new Race();//實現了Callable接口
	
	Future<Integer> result=service.submit( r);
	
	int number = result.get();
	
	System.out.println(number);
	
	service.shutdownNow();
}

}接口

相關文章
相關標籤/搜索