Question ID :988386106781
Consider the following method:
public void getLocks(Object a, Object b)
{
synchronized(a)
{
sunchronized(b)
{
//do something
}
}
}
and the following instantiations:
Object obj1 = new Object();
Object obj2 = new Object();
obj1 and obj2 are accesible to two different threads and the threads are about to call the getLocks() method.
Assume the first
thread calls the method getLocks(obj1, obj2).
Which of the following is true?
a)The 2nd thread should call getLocks(obj2,obj1)
b)The 2nd thread should call getLocks(obj1,obj2)
c)The 2nd thread may call function in any order
d)The 2nd thread should call getLocks when 1st thread exits
e)None of above
The correct answer is A , i think it should be C can any 1 explain thanks in advance.
Yasir Sufyan Qureshi