This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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
 
Consider Paul's rocket mass heater.
 
subject: THREADS :PLEASE HELP
 
Similar Threads
urgent:PLS HELP
Help.....Thread
Question from Khalid book
confused on thread topic
not at all able to understand what is happening in this program