Both methods lock the same monitor. Therefore, you can’t simultaneously execute them on the same object from different threads (one of the two methods will block until the other is finished).
More Related Contents:
- What does ‘synchronized’ mean?
- Difference between wait() and sleep()
- Avoid synchronized(this) in Java?
- Difference between volatile and synchronized in Java
- How to use wait and notify in Java without IllegalMonitorStateException?
- Is there an advantage to use a Synchronized Method instead of a Synchronized Block?
- Synchronizing on String objects in Java
- “implements Runnable” vs “extends Thread” in Java
- Java synchronized method lock on object, or method?
- Java Synchronized Block for .class
- Synchronization of non-final field
- Happens-before relationships with volatile fields and synchronized blocks in Java – and their impact on non-volatile variables?
- Is ConcurrentHashMap totally safe?
- In Java critical sections, what should I synchronize on?
- Turning an ExecutorService to daemon in Java
- What is the difference between a synchronized method and synchronized block in Java? [duplicate]
- Should you synchronize the run method? Why or why not?
- Java volatile modifier and synchronized blocks
- Difference between “wait()” vs “sleep()” in Java
- Java Multithreading concept and join() method
- Difference between Synchronized block with wait/notify and without them?
- Do two synchronized methods execute simultaneously
- If a synchronized method calls another non-synchronized method, is there a lock on the non-synchronized method
- What is the difference between Thread.start() and Thread.run()?
- Why use a ReentrantLock if one can use synchronized(this)?
- Is it safe to construct Swing/AWT widgets NOT on the Event Dispatch Thread?
- Is the Swing repaint() method still safe to use outside the EDT in Java 7+?
- Is having a single threadpool better design than multiple threadpools
- Will a chain of method calls (CompletableFuture API) execute asynchronously if the first method in a chain is asynchronous?
- Concurrent read/write of named pipe in Java (on windows)