wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Thread priority Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Thread priority" Watch "Thread priority" New topic
Author

Thread priority

Nick Petas
Ranch Hand

Joined: Jan 31, 2007
Posts: 38
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.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

"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

Joined: Jan 31, 2007
Posts: 38
ok.I think it is ok now.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37962
    
  22
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?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41096
    
  44
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).


Ping & DNS - my free Android networking tools app
 
 
subject: Thread priority
 
Similar Threads
waitfor on a process
View not coming after certain screen
Synchronization and Locks
Protecting for loop values
Good and Evil: Assumptions Thread