Solved

Synchronized method - testing junit

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

820 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