java多线程
package com; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; public class TestMain { public static void main(String[] args) throws Exception{ ExecutorService executorService = Executors.newFixedThreadPool(10); executorService.execute(new Runnable() { public void run() { try { Thread.sleep(5000); } catch (InterruptedException e) {} System.out.println("Asynchronous task"); } }); executorService.shutdown(); boolean success = executorService.awaitTermination(5, TimeUnit.HOURS); if(success) { System.out.println("success"); }else { System.out.println("fail"); } System.out.println("over"); } }