int main(int argc, char **argv) { // # general FLTK initialization w/o Fl::lock() Fl_Double_Window* w = new Fl_Double_Window(200, 200, "Single Thread"); // # window initialization goes here w->end(); w->show(); browser1->add("Prime numbers:"); browser2->add("Prime numbers:"); // Enable multi-thread support by locking from the main thread. Fl::lock(); // # Start (child) threads AFTER Fl::lock() ... // One thread displaying in one browser fl_create_thread(prime_thread, prime_func, browser1); // Several threads displaying in another browser fl_create_thread(prime_thread, prime_func, browser2); // # start more threads. // # You could do even more FLTK initializations here // # w/o interfering with the child threads because // # the FLTK lock is held... // # WE MUST NOT release the lock because otherwise // # the child threads could acquire the lock before // # the FLTK event loop gets started (race condition). Fl::run(); return 0; }