Threads
We have already introduced the concept of a thread as a unit of computation that can be scheduled. During design, the principal trade-off concerns the number of threads. Increasing the number of threads can simplify certain algorithms and techniques but increases the risk of sequencing problems. Reducing the number of threads reduces sequencing problems but makes the software more rigid and often more inefficient.
Synchronization
When two or more threads must access the same memory location, a mechanism is needed to prevent the two threads from interfering with each other. Two threads may try to execute a method that modifies a data value at the same time. Some languages, such as Java, provide a language keyword that automatically adds ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access