我不明白为什么这只打印 2 个活动线程。
/* worker from the example */
for(int i = 0 ; i < 4 ; ++i){
Worker worker = new Worker(articles, factory);
worker.start();
workers.add(worker);
}
System.out.println("Number of active threads : " + Worker.activeCount());
我的 Worker 类是这样写的:
class Worker extends Thread{}