Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我修改了 Qt 的广播发送器示例,使其具有十个线程,并且在每个线程中启动一个计时器,但仅触发第一个线程的计时器。如何为每个线程运行一个计时器?
计时器仅在线程具有事件循环时才起作用。
几年后,在操作系统课程中,我了解到:定时器是每个进程的东西。当操作系统内核发送计时器触发器时,即使当前正在运行的任何线程都会收到调用并处理它。所以我不能以直截了当的方式为每个线程设置十个计时器。