• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

the priority about the thread.

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I read the explaination about the priority about the thread.
" the Thread gets the same priority as the thread that has created it."
I am confused about this.
Say, thread A create thread B. A and B have the same priority?
Another question:
class A extends Thread{
}
class B extends Thread{
}
class C{
public static void main(String[] args){
A a= new A();
B b= new B();
}
}
Is there anything talking about the priority about thread A and thread B?
Thanks in advanced
Simon
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In this particular case both A and B will inherit the priority of the main system thread that created them, correct me if I'm wrong, which is 5.
regards,
VG.
 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I read the explaination about the priority about the thread.
" the Thread gets the same priority as the thread that has created it."


Hi Simon,
This is true.
I Take your example - thread A create thread B.
Now A and B will have the same priority. (refer p284 Khalid).


Another question:
class A extends Thread{
}
class B extends Thread{
}
class C{
public static void main(String[] args){
A a= new A();
B b= new B();
}
}
Is there anything talking about the priority about thread A and thread B?


Here, the threads A and B will get the priority of main thread since it is the parent.
Also, when you don't set the priority of a thread, it assumes a Thread.NORM_PRIORITY.
Hope this helps,

------------------
Regards
---------
vadiraj

*****************
There's a lot of I in J.
*****************
 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, vadiraj
What means "thread A creates thread B"? Is there typing error? or Do youreally suppose thread A creats Thread B. I think it is our responsible to try our best to give the correct explanation, right?
Your other statements are right. A priority of a thread inherited from its parent, that is, which creats the current thread until the priority is changed explicitly.
regds
George

[This message has been edited by George Toronto (edited January 02, 2001).]
[This message has been edited by George Toronto (edited January 02, 2001).]
 
vadiraj vd
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi George,
Thanks for your reply.
I assumed the fact that in Java every program runs as a thread.
For example, the main thread which is created by JVM.
So in main method(which is indeed a thread) we can create another
thread. That's what I mean by saying Thread A creates Thread B.
Correct me still if I'm wrong.

------------------
Regards
---------
vadiraj

*****************
There's a lot of I in J.
*****************
 
Bring me the box labeled "thinking cap" ... and then read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic