// This could be local to main(), if you want, but that limits your // flexibility (e.g., to dynamicall change the # of threads) Thread *worker[ numberOfThreads ]; // This needs to be visible to the display function and the worker threads Barrier *displayBarrier; // changes to main routine for multi-threaded ray tracer int main(int argc, char** argv) { . . . // Initialize synchronization mechanisms (+1 because of the display thread) displayBarrier = new Barrier( numberOfThreads+1 ); // Create computation threads for (int i=0;i < numberOfThreads ;i++) { worker[i] = new Thread( i ); worker[i]->Create( WorkerLoop ); } . . . // Start execution of the OpenGL program glutMainLoop(); return 0; }