File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Help.....Thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Help.....Thread" Watch "Help.....Thread" New topic


Aru Ven
Ranch Hand

Joined: Sep 28, 2000
Posts: 199
Hi All,
Can anyone explain me the output of the program.....

Thanks in advance.
Vladimir Kositsky
Ranch Hand

Joined: Nov 03, 2000
Posts: 116
both treads increment i,k, and j in each of eternal loop invocation and return equal values.
so letters printed if workWithoutLocks( ) executed between first and second variables increment , and it is possible without any legimitacy.
see example 9.6 Mugal and Pasmussen
shalini Rajan

Joined: Dec 02, 2000
Posts: 9
Hi Aruna,
I can't predict the result.Itz displaying infinite 'j' thatz right but some time it displays i & k also.I don't know why?.Lets wait for others to answer.
Praveen Zala
Ranch Hand

Joined: Jul 02, 2000
Posts: 118
Hi Aru,
The code that u have posted started printing k,j.........and so
on prints the same witout stopping ...infinitely....
Wonder why it does that !
Nasir Khan
Ranch Hand

Joined: Nov 04, 2000
Posts: 135
I changed the line if (j1 != j2) System.out.println("j");
with if (j1 != j2) System.out.println(j1+"j"+j2);
and found that the condition j1 != j2 is true after going through several loops ..
It seems that after sometime one thread lags behind the other one
I agree. Here's the link:
subject: Help.....Thread
jQuery in Action, 3rd edition