Tag: thread priority

线程优先级不能按预期工作?

我使用线程优先级创建了一个程序,我获得了优先级为1的线程和优先级为10的线程的相同点击次数,这令我感到困惑,为什么我得到这个 class clicker implements Runnable { int click = 0; Thread t; private volatile boolean running = true; public clicker(int p) { t = new Thread(this); t.setPriority(p); } public void run() { while (running) { click++; } } public void stop() { running = false; } public void start() { t.start(); } } class hilopri […]