aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes very urgent - threads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "very urgent - threads" Watch "very urgent - threads" New topic
Author

very urgent - threads

gayathri bhushan
Ranch Hand

Joined: Jan 29, 2001
Posts: 39
if the priority for the thread is not specified during creation whaat is the priority of that thread?
is it normal priority set by the constant NORM_PRIORITY or is it that the priority is the same as the priority of the thread that creates it...please answer soon
thank you in advance
gayathri
Pratiti Naphade
Ranch Hand

Joined: Mar 13, 2001
Posts: 39
I think it is set to normal priority
huiying li
Ranch Hand

Joined: Feb 12, 2001
Posts: 68
Here is a quote from the API on Thread class
"When code running in some thread creates a new Thread object, the new thread has its priority initially set equal to the priority of the creating thread."

SCJP
Ishaan Mohan
Ranch Hand

Joined: Jan 20, 2001
Posts: 115
Hi,
The priority is the same as the priority of the thread that creates it...
A thread inherits the priority of its parent thread.
Martha Yeh
Greenhorn

Joined: Jan 31, 2001
Posts: 18
hi there,
according the Khalid's book p.284--
If no explicit thread priority is specialed for a thread, it's given the default priority of 5(Thread.NORM_PRIORITY)
also, a thread inherits the priorty of its parent thread. usually the thread scheduler decides to let the thread with the highest priority in the Ready-to-run state to get CPU time.
hope this help. good weekend.
^__^*
martha
gayathri bhushan
Ranch Hand

Joined: Jan 29, 2001
Posts: 39
thank you all...but still, iam confused...
i read from khalid that thread is set to normal priority but in mock exams they say its the parent threads priority...
so if i have to answer in exam which one should i choose?
for eg:
state true or false
if a thread is not assigned a priority during creation the priority assigned to it is Thread.NORM_PRIORITY
please clear my doubt soon as iam taking the exam tomorrow
Athiveera Kugan
Greenhorn

Joined: Mar 21, 2001
Posts: 15
hai!
All Thread including current main thread are set to normal priority(ie serPriority as 5) initially. So obviously it can be answered as "TRUE".
<blink> s.a.kugan</blink>
------------------
s.a.kugan


<I> s.a.kugan</I>
ryan burgdorfer
Ranch Hand

Joined: Jan 24, 2001
Posts: 219
Yes, I agree, it would be TRUE because inheriting priority from the creating thread IS setting a priority at creation. So you can infer into the question:
If a thread is not assigned a priority during creation [i.e. the thread does not inherit its priority from another thread] the priority assigned to it is Thread.NORM_PRIORITY
Of course the question this raises is when would a thread NOT inherit priority from its creating thread?
(Other than in the case of the <h4>main()</h4> thread)...
------------------
  • Ryan Burgdorfer
  • Java Acolyte in
  • Columbus, OH USA


<UL TYPE=SQUARE><I><LI>Ryan Burgdorfer<BR><LI>Java Acolyte</I></UL>
Martha Yeh
Greenhorn

Joined: Jan 31, 2001
Posts: 18
it's True
read p.284 carefully the last 2 pargraph.. u will get it
good weekend again.
martha
huiying li
Ranch Hand

Joined: Feb 12, 2001
Posts: 68

If a thread does not specify a priority, then it is inherited from its parent thread, which may have set a different priority than Thread.NORMAL_PRIORITY when it is created.

[This message has been edited by huiying li (edited March 24, 2001).]
Mohammad Atif
Greenhorn

Joined: Mar 20, 2001
Posts: 6
the thread will always have its priority inherited from the thread which created it.
Balu Ramachandran
Greenhorn

Joined: Oct 16, 2000
Posts: 16
hi,
it's normal priority ----->5
don't confuse.


------------------
R.Balu


R.Balu
Stevie Kaligis
Ranch Hand

Joined: Feb 04, 2001
Posts: 400
In my opinion,
every thread instance, is a member of excactly one thread group. A thread Group can have both threads and other thread Groups as its member.
when a Java application is started, the JVM creates the main thread group as a member of "system thread group". A main thread is created in this main thread group to run the main() method of the application.
If main() method spawns a thread, that thread INHERITS the user-thread status of the original thread (main), including its PRIORITY.
By Default, all new user-created thread and thread group will become the member of this main thread group UNLESS another THREAD GROUP is passed as the first argument of the new statement constructor method.
for example :
ThreadGroup javaRanch = new ThreadGroup("MyTHREADGROUP");
Thread thread = new Thread(javaRanch, "MyThread");
You create a "thread", and this thread is a member of "javaRanch" ThreadGroup. By doing this, "thread" will inherits all status from javaRanch Thread Group, including the PRIORITY.
so i choosed "FALSE".

stevie
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: very urgent - threads