Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

is tk thread safe?

Status
Not open for further replies.

rabins

Programmer
May 6, 2002
1
US
Hi

is tk thread safe? If so can i use all c library func of tk ? where can i learn
about tk_main_loop in such case?


i know that tcl is thread safe under some
restrictions of reffering a tcl_interp.

10x
R.

 
Tk is not completely thread-safe, but that's true of many GUI toolkits. Thread safety is difficult and time-comsuming to implement, and slows down code running on single-CPU systems, so many GUI toolkits don't bother with thread-safety.

However, you can easily adapt the standard solution to this limitation: only one thread owns the GUI. All GUI code should be executed by only one thread in your applicaton. If other threads want to update the GUI, they do so by passing messages to the GUI manager thread.

Of course, this is very similar to Tcl's overall threading model. Only one thread can control a Tcl interpreter. If another thread wants to interact with the interpreter, it must send a message to the interpreter, which is added to the interpreter's event queue. Of course, a thread can own multiple interpreters, and multiple threads can have their own interpreters, so you can get quite complex if you like. But when you start to mix in Tk code, only one of those interpreters should be managing your GUI. - Ken Jones, President
Avia Training and Consulting
866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top