• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

doubt in thread

 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 .
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is Thread..You can not predict the behaviour.
Even in same system...right guys???
 
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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).
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.



 
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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,
 
Sandeep Sachan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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??
 
I’m tired of walking, and will rest for a minute and grow some wheels. This is the promise of this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic