Threads are lightweight processes that share certain areas of the memory, unlike regular processes. This makes threads very efficient, but it also introduces additional complexities regarding memory management. You can protect your shared data by making it accessible (for reading and writing) to only one thread at a point of time. Other techniques include defining immutable classes (the states of which can’t be modified) and defining volatile variables. In this section, you’ll identify the data that’s shared across threads and needs to be protected, and the related techniques.