Solved

Synchronized method - testing junit

Posted on 2009-04-01
2
882 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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
github account with ecipse 1 47
HSSFWorkbook cannot be resolved error 10 70
Way to decrease size of apk file 9 69
hibernate insert example 13 29
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
The viewer will learn how to implement Singleton Design Pattern in Java.

778 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