• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Thread priority

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a main class that starts two threads that write some charachers on the screen.
If I add a System.out.print("something") after the two start commands that something appear before the characters that the threads output yo the screen?
Why so?
Thank you very much.
 
Marshal
Posts: 24594
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"skiabox", welcome to JavaRanch. We're a friendly bunch here, but we do require our ranch hands to use real screen names. You can read the policy here.

So please change your screen name to a real name. You can do that here. And be aware that not following the policy may lead to termination of your account.
 
Nick Petas
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok.I think it is ok now.
 
Marshal
Posts: 64654
225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't understand the question, I am afraid. Please supply more details, eg what you are printing on screen.

You do realise that the two Threads run independently of each other, so they will not necessarily carry out actions in a particular order, particularly things like input and output which can take thousands or millions of times longer to execute than calculations?
 
Rancher
Posts: 43009
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's no telling which of the 3 threads will be scheduled to run (or to be started) first. The results could be different on different machines, or on different JREs on the same machine, and even on the same JRE on the same machine (although that's unlikely).
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!