[ Team LiB ] Previous Section Next Section

Chapter 21. Multi-Threaded Tcl Scripts

This chapter describes the Thread extension for creating multi-threaded Tcl scripts.

Thread support, a key feature of many languages, is a recent addition to Tcl. That's because the Tcl event loop supports features implemented by threads in most other languages, such as graphical user interface management, multi-client servers, asynchronous communication, and scheduling and timing operations. However, although Tcl's event loop can replace the need for threads in many circumstances, there are still some instances where threads can be a better solution:

  • Long-running calculations or other processing, which can "starve" the event loop

  • Interaction with external libraries or processes that don't support asynchronous communication

  • Parallel processing that doesn't adapt well to an event-driven model

  • Embedding Tcl into an existing multi-threaded application

    [ Team LiB ] Previous Section Next Section