This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Threads and Synchronization and the fly likes THREADS :PLEASE HELP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "THREADS :PLEASE HELP" Watch "THREADS :PLEASE HELP" New topic
Author

THREADS :PLEASE HELP

Raj Mehra
Ranch Hand

Joined: Nov 20, 2000
Posts: 51

Dear friends,
Can anyone explain to me why the following program, doesnot show any output.
Thnx in advance.


SCJP2 2001 84%<br />SCJD2 2003 100%
khudiram Barik
Greenhorn

Joined: Feb 12, 2001
Posts: 17
This may be possible.
Since the doIT() is not synchronized both the thread can access the method concurrently. When the first one finishes the 1st synchronized block and goes for the statemnt j1++, the second one can enter into 1st synchronized block and so on, we can never predict the locks. Since the variables are volatile concurrent changes will effect both the threads and hence you may not have the System.out.println statements get executed.
Thanks.
khudi
 
Have you checked out Aspose?
 
subject: THREADS :PLEASE HELP
 
It's not a secret anymore!