• Post Reply Bookmark Topic Watch Topic
  • New Topic

How the lock will processed with multiple threads

 
himkar dwivedi
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I want to know how the threads will wait for following cases:

1:
public class One{

public synchronized void getA();
public synchronized getB();
}

2:
public class Two{

public void getA();
public void getB();
}

3:
public class One{

public void getA();
public static void getB();
}

4:
public class One{

public static void getA();
public static void getB();
}

So, When there are two thread t1 and t2 and want to access getA and getB on same instance at same time.
A. Lock will happen on Object or only synchronized methods.

And i need some references where i can get some nice tutorial about threading with OOPs concept and scenario bases solutions.

Thanks
 
Jim Hoglund
Ranch Hand
Posts: 525
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch. Just search the Ranch or the Sun site. There's a ton of
information available on threads, object locks and method synchronization. It's
best to come here for help when you don't understand a topic.

Jim ... ...
 
Rob Spoor
Sheriff
Posts: 20817
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to Threads and Synchronization.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!