16.10. Summary

Threads can be used for a variety of applications. In some cases, using threads makes software design simpler by letting you separate various pieces of work into independent chunks rather than coordinating them in a central routine. In other cases, threads can improve efficiency by letting you continue processing while a routine is waiting for user input or a network connection.

However, threaded programs tend to be more difficult to understand and debug, and improper synchronization can lead to inconsistent results. So use threads with some caution.

A particular difficulty arises when threads are used for animation or when graphics change dynamically based on user interaction. A variety of potential solutions are possible, but ...

Get Core Web Programming, Second 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.