previous |
start |
next
Synchronized Methods
- By declaring both the deposit and withdraw
methods to be synchronized
- Our program will run correctly
- Only one thread at a time can execute either method on a given
object
- When a thread starts one of the methods, it is guaranteed to
execute the method to completion before another thread can execute
a synchronized method on the same object.
previous |
start |
next