Thread thread2 = new Thread(threadGroup, new Runnable() { public void run() { //do something. } }, "No.2"); thread2.start();
-這個是Future方式 FutureTask<String> futureTask = new FutureTask<String>(new Callable<String>() { public String call() throws Exception { TimeUnit.SECONDS.sleep(5); return "game over!";java
} }); new Thread(futureTask).start(); System.out.println(futureTask.isDone()); System.out.println(futureTask.get());
#java線程池線程