Two Laptop Bag*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes the priority about the thread. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "the priority about the thread." Watch "the priority about the thread." New topic
Author

the priority about the thread.

Simon Sun
Greenhorn

Joined: Dec 07, 2000
Posts: 20
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
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

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
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
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.
*****************
 
wood burning stoves
 
subject: the priority about the thread.
 
Similar Threads
Thread priority
Thread Priority
thread
synchronized
Thread Priority