Hello. I study thread synchronization in Java, and, as I understood from the book, there are several ways to synchronize: through the synchronized , through the use of ReentrantLock and through the wait / notify .
- Did I select these methods correctly?
- Are these ways self-sufficient? Is it possible to use each of them without resorting to the others?
- The combination of these methods is impossible / undesirable / permissible / desirable?
ReentrantLockinjava.util.concurrentthere are a lot of other interesting things for different occasions.synchronizedis a simple, coarse solution unless you are interested in performance.wait/notify- very low-level operations, you need to understand how they work, but to use something more high-level. - Nofate ♦