Thread Safety

The Tcl C library is thread-safe. This means you can use Tcl in an application that uses threads. The threading model for Tcl is that a thread can have one or more Tcl interpreters, but a Tcl interpreter cannot be used by different threads. For communication between threads, Tcl provides the ability to send Tcl scripts to an interpreter in another thread. You can also create an extension that implements shared data and does its own locking.

The Tcl C library provides mutex variables, condition variables, and thread local storage. These primatives are used by Tcl internally, and they are meant to be used by Tcl extensions to serialize access to their own data structures. The Tcl library allows different implementations of the threading ...

Get Practical Programming in Tcl & Tk, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.