This week's book giveaway is in the Open Source Projects forum.
We're giving away four copies of Spark in Action and have Jean-Georges Perrin on-line!
See this thread for details.
Win a copy of Spark in Action this week in the Open Source Projects forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Threads...

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
It may be silly doubt? but please expalin..
What is the difference between Thread.start() and Thread.run(),
start() method is internally calling the run()..
Can i use run() method directly instead of t.start()..
thanks in advance..
Suresh
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
though thread.start() method internally calls run(), it starts the new Thread.
where as if u just call run() method directly it will execute the code with in run method but won't start a new Thread. so there is a difference........Ajit
 
suresh seeram
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not able to under stand this problem clearly..
can any one explain this..

Which of the follwoing statements are true..
Ans:
One cannot be certain whether any of the letters i,j and k will be printed during execution
thanks in advance..
regards,
Suresh

[This message has been edited by Marilyn deQueiroz (edited October 11, 2001).]
 
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suresh,
The answer is correct
If you observe the code,
doit();
check();
are one after the other so threads may not have anything to synchronize
The only way the output is possible is when check() gets executed inbetween the incrementing code. This creates an uncertainity in the output since it becomes now a OS specific
This code may work in solaris as pre-emptive nature in Windoze as RoundRobin nature
Therefore the output is unpredictable
Ragu

[This message has been edited by Ragu Sivaraman (edited October 11, 2001).]
 
suresh seeram
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ajit and Ragu,

Thanks for your help..

Regards,
Suresh
 
    Bookmark Topic Watch Topic
  • New Topic