Search your topic in Java2share
Home > FAQs
eXTReMe Tracker

Multi Threading FAQs

Untitled Document

Q17.  How to get and set name of a Thread?
Ans.   For every Thread in java there is a name. To set and get the name of a Thread we can use the following methods. All methods are final.
1.Public final void setName(String name); - To set the name of a Thread
2.Public final String getName(); - To get the name of a Thread.

Q18. What is the range of Thread priority in java?
Ans.   The valid range of a Thread priority is 1-10. (1 is least priority and 10 is highest priority)

Q19.  Who uses Thread priority?
Ans.   Thread Scheduler uses priorities while allocating CPU. The Thread which is having highest priority will get chance first for execution.

Q20.  What is the default priority of the Thread?
Ans.   The default priority only for the main thread is 5 but for all remaining threads default priority will be inheriting from parent to child. Whatever priority parent thread has the same will be inherited to the child thread.