File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: THREADS :PLEASE HELP