java - Why does the priority from getPriority inside a new thread differ from the priority in the calling thread? -


For example, why do the following codes produce a priority of 7?

  public class test {public static zero main (string [] args) {thread thread = new thread (new A ()); Thread.setPriority (7); System.out.println ("in main:" + thread.getPriority ()); Thread.start (); }} Class A Extended Thread {@Override Public Zero () {System.out.println ("in thread:" + this.getPriority ()); }}  

Output:

  In main: 7: 5 in thread  

  new thread (new A ());  

You are treating new A () as the Runnable and assign it to a different thread Examples.

does not affect the new threads example threads based on its runnabel .

>

You should use new A () directly.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -