Making Your Application Thread-Safe

Many new concepts were covered in this chapter, from deadlocks to thread scheduling algorithms. Probably the most important concept to walk away from this chapter with, other than understanding the Thread API, is the concept of a critical section.

As stated earlier, a critical section is a part or multiple parts of an application that can be accessed simultaneously from multiple threads. If an application has more than a single thread running and there is shared data that can be accessed, this area has to be protected. By using the keyword synchronized, these critical sections can be made safe to allow multiple threads in an application to share the data. One of the most important things to remember when making ...

Get Special Edition Using Java 2 Standard 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.