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
Vlad G
Greenhorn
Joined: Dec 28, 2000
Posts: 17
posted
0
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.
vadiraj vd
Ranch Hand
Joined: Dec 15, 2000
Posts: 68
posted
0
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. *****************
Regards<BR>---------<BR>vadiraj<P><BR>*****************<BR>There's a lot of I in J.<BR>*****************
George Toronto
Ranch Hand
Joined: Dec 30, 2000
Posts: 78
posted
0
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
Joined: Dec 15, 2000
Posts: 68
posted
0
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. *****************