From the course: Java Concurrency Troubleshooting: Latency and Throughput
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Synchronization and locking - Java Tutorial
From the course: Java Concurrency Troubleshooting: Latency and Throughput
Synchronization and locking
- [Instructor] Synchronization and locking are fundamental to programming and computing in general, and they can both get pretty complicated. So we're not going to go into too much detail of how either of them work per se. Synchronization in Java is a mechanism that you use to maintain orderly, one-by-one access to a field, a method, or data structure. A lock is a component that you use to maintain that order in the synchronization process. Now, close your eyes and imagine a restaurant, busy kitchen and all that. It has exactly one table set for one guest. But there's a line of customers waiting outside. The only way to maintain orderly access to that single table is to provide only one door. Everyone has to wait their turn. Can you see how this can quickly become a problem? In this analogy, the guests waiting outside are threads. The restaurant is the JVM. The table, a method or a data structure. This is the story of a…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.