• 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

very urgent - threads

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it is set to normal priority
 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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."
 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
The priority is the same as the priority of the thread that creates it...
A thread inherits the priority of its parent thread.
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Martha Yeh
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it's True
read p.284 carefully the last 2 pargraph.. u will get it
good weekend again.
martha
 
huiying li
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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).]
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the thread will always have its priority inherited from the thread which created it.
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
it's normal priority ----->5
don't confuse.


------------------
R.Balu
 
Ranch Hand
Posts: 400
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
reply
    Bookmark Topic Watch Topic
  • New Topic