title: Linux: How to programmatically detect idle threads in a process?
body: <p>Currently a low priority scrubber task is launched periodically in a process. At times due to lock contention this low priority task can interfere with other high priority tasks. I'd like to run such low priority task opportunistically when other threads in the process are idle(blocked waiting for a lock/not running state). I understand that once such low priority task is launched other high priority tasks can start running soon after, however I'm looking to avoid running such low-priority task if other threads in the process are already busy.</p>