Cod*_*ock -1 java concurrency multithreading runnable
我试图拥有一堆可以一次启动的可运行线程.就像是
First(new Thread() {
public void run() {
//do something
}
});
Run Code Online (Sandbox Code Playgroud)
我想要做什么是不可能的?
您可以使用单线程Executor
ExecutorService service = Executors.newSingleThreadedPool();
service.submit(runnable1);
service.submit(runnable2);
service.submit(runnable3);
Run Code Online (Sandbox Code Playgroud)