aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes doubt in thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "doubt in thread " Watch "doubt in thread " New topic
Author

doubt in thread

Divya Gehlot
Ranch Hand

Joined: Sep 10, 2006
Posts: 243

Can any one explain me the above program as ahy its behaving inconsistently.As on linux machine its giving different output and windows its different.
Compilation without error, but the exact output cannot be determined.
above is the correct answer for above .


SCJP1.5(81%), SCDJWS(94%), next mission SCEA (but need to wait or that)
Ankith suresh
Ranch Hand

Joined: Jun 07, 2007
Posts: 42
That is Thread..You can not predict the behaviour.
Even in same system...right guys???
Manfred Klug
Ranch Hand

Joined: Jun 04, 2007
Posts: 377
Originally posted by Ankith suresh:
That is Thread..You can not predict the behaviour.
Even in same system...right guys???

Right.

But remember:
It is possible that you always see the same behaviour on one machine, and that you are very surprised if you start the program on another machine (even if both have the same OS).
Sandeep Sachan
Greenhorn

Joined: Sep 17, 2005
Posts: 9
Divya Gehlot!
Well if it's regarding Thread then your cann't prove and even cant say which thread is going to start first
As i have checked in to linux as will in to WindowsXp, "When it comes with Thread it's cant predictable"

Try this out.


Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
Hi,

Agreed!

There is a single object and three threads are working on that. Behavior may
vary from execution to execution or plate-form wise. It may be same most of
the time or vary at each execution. It depends, how thread scheduling is
taking place.


Thanks,


cmbhatt
Sandeep Sachan
Greenhorn

Joined: Sep 17, 2005
Posts: 9
Noopss

even theadscheduling is not working with Java when it come to Threads.
Yes, it differ from machine to machine and even compilation, actually in both the cases CPU's TimeCycle changes and there thread gets the way to execute. i want to know, why this kind of machanise Java supports??
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: doubt in thread