How to utilize a thread pool with pthreads?
问题 I have a queue of jobs and I want to make a pool of four threads where I can throw my jobs at. What I am stuck at is in how to make the threads and keep them suspended while there is no work. JOB QUEUE | job1 | job2 | job3 | job4 | .. THREAD POOL | thread1 | thread2 | thread3 | thread4 | To create the threads I have currently at the initialisation point: for (t=0; t<num_of_threads; t++){ pthread_create(&(threads[t]), NULL, doSth2, NULL); } Where num_of_threads=4 and doSth2 is a function with