You obviously did not read the most important part of FLTK documentation with regards to concurrent programming: http://www.fltk.org/doc-1.3/advanced.html#advanced_multithreading . Please read it carefully.
You have two alternatives:
Use
Fl::awake()
to send message to the main (gui) thread. Main thread can check the message usingFl::thread_message()
and create whatever widget you like.Between calls to
Fl::lock()
andFl::unlock()
call FLTK methods.
Finally, you have a very nice demo in the $FLTK_SRC/test directory, where $FLTK_SRC is the directory where you hold FLTK source tree. If you do not have it, download it.