Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Need Help for assignment: SYNCHRONIZATION  RSS feed

 
Rajiv Pai
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I am New to Programming language and also new to this site.
I needed help with an assignment related to Thread Synchronization

The statement is :

There is a class called Hello with Two Methods m1() & m2() and both are synchronized.

Two threads are running called A and B concurrently.
Thread A is Calling m1() method with an object h1.

What will happen when thread B is trying to call m2() method with the same object h1?

This is how far i am done with the code...




 
Henry Wong
author
Sheriff
Posts: 22836
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

As a recommendation, you may want to write your test with synchronized instance methods -- and not static methods. The reason is, from your code, it looks like you may want to test the case with more than one Hello02 object.

Henry
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!