I have a doubt regarding Java Synchronization . I want to know if I have three Synchronized methods in my class and a thread acquires lock in one synchronized method other t
Yes, all threads but the one which acquired the lock will have to wait until the lock gets released again to be able to execute one of the three synchronized methods.
Remember, a synchronized method is the same as a normal method surrounded by
synchronized(this) {
// method body
}
If a class has 4 synchronize methods, then yes at a time only one thread will have access to those methods. I guess doubt here was, each thread can access diff synchronized methods at a time for single class instance. The answer is no. Only one thread can access synchronized methods at a time.