-
Thread question
If someone could answer/explain this i'd greatly appreciate it.
class MyClass{
public synchronized void func1( ){
……
}
public synchronized void func2( ){
……
}
}
MyClass myObj=new MyClass( ); // shared by both thread
Thread 1
……
myObj.func1( );
…… Thread 2
……
myObj.func2( );
……
Do you think Thread 1 and Thread 2 can run myObj.func1() and myObj.func2() during the same time? Why or why not? Explain in detail.
-
What do you think? We are not simply going to do your homework for you. The key point is the "synchronized" keyword and it's location. What does "synchronized" do? What is being synchronized on?