Solved

Synchronized method - testing junit

Posted on 2009-04-01
2
845 Views
Last Modified: 2012-05-06
I have a method which was not threadsafe, i have now Synchronized  it.

Just wondering if i can use Junit it prove that it now working syncronsouly ? I was thinking of instantiating a few threads and then invoking the method.....but not sure this is the correct way.

Just need a Junit test to prove that the method is now Synchronized

thanks
0
Comment
Question by:Molko
  • 2
2 Comments
 
LVL 24

Accepted Solution

by:
sciuriware earned 500 total points
ID: 24043821
Your tests should reflect a worst case scenario of a life situation.
JUNIT is not enough in this case.
You should prove that a 'random rain' of calls on this method doesn't
lead to hangs or race conditions.

So, what's the purpose of the method.
Don't answer, just think and analyse.

;JOOP!
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 24286485
:)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now