i have couple of doubts regarding synchronization in
java threads
1)When we put synchronize before any method that makes sense only if the same object conatining the synchronized method
is shared among different threads. Lets say we have a class class1 containg synchronized method1. Now if two threads(say t1
and t2) sharing the same insatnce of class1(say object1) then only synchronized keyword will come into picture .
But not ,if we have t1 and t2
thread accessing the same synchronized method 1 on different instances of class1
2) when a thread t1 enters a synchronize method (on object o1)then it gets the lock on complete object. then even if thread t2 want to access
any other method of the same object o1 either it is synchronized or not then it can not access
3)How the locking happens in case of static synschronized methods
4)Say a thread t1 called the wait method on method1 of object1. Then if another thread t2 callled the notify on method2 of sameobject. Does it make the thread
t1 runnable.
5)one more question reagaring 4 if 10 threads are waiting on object then after calling notify which thread out 10 will be runnable? Will it any random
thread?