wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Thread Related Problem 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 "Thread Related Problem " Watch "Thread Related Problem " New topic
Author

Thread Related Problem

Rohan Kayan
Ranch Hand

Joined: Sep 17, 2004
Posts: 123
Q12. If one does not assign a priority to a Thread object, it assumes a priority of ___ by default.
0
5
1
None of the above


This is the question from www.tipsmart.com , what will be the ans of this according to me , it should be 5 , but site is giving ans "None of the above" . I am confused why ??? Please help me out ...

Q10. State which of the following statements are True.
(1) Concurrent Java programs can exhibit deterministic behavior, by providing mechanisms for synchronizing.
(2) Threads have parent-child relationships.
(3) When the thread is created, it is not yet active


What will be the ans for this question also , site is saying that Threads don't have parent-child relationships. But I my view they have parent child relationship .
[ May 18, 2005: Message edited by: Rohan Kayan ]

SCWCD 1.4, SCJP 1.4
Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026
class ThreadPriority extends Thread{
public static void main(String[] args) {
ThreadPriority one = new ThreadPriority();
System.out.println(one);
System.out.println(one.getPriority());
System.out.println(one.currentThread().getName());
}
}

Output:

Thread[Thread-0,5,main]
5
main


Here "5" is the threads priority and "main" is Threads Name


Servlet Spec 2.4/ Jsp Spec 2.0/ JSTL Spec 1.1 - JSTL Tag Documentation
Nischal Tanna
Ranch Hand

Joined: Aug 19, 2003
Posts: 182
A thread's default priority is the priority of its parent thread (not necessary to be main whose priority is 5). Hence "none of the above"


Thnx
Rohan Kayan
Ranch Hand

Joined: Sep 17, 2004
Posts: 123
Reply for Vishnu
But if we set the priority of main thread as 10 and then I will create a thread with out any priority specified , the the default priority of the child thread will be 10 . Then how can we say that the default priority of thread is 5 ??
[ May 18, 2005: Message edited by: Rohan Kayan ]
Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026

But if we set the priority of main thread as 10 and then I will create
a thread with out any priority specified , the the default priority of
the child thread will be 10 . Then how can we say that the default
priority of thread is 5 ??


The question says
If one does not assign a priority to a Thread object

as Nischal said a threads priority depends on its parent threads priority



Ans:
8
8
8
8
Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026

But if we set the priority of main thread as 10 and then I will create
a thread with out any priority specified , the the default priority of
the child thread will be 10 . Then how can we say that the default
priority of thread is 5 ??


The question says
If one does not assign a priority to a Thread object

as Nischal said a threads priority depends on its parent threads priority



Ans:
8
8
8
8
 
 
subject: Thread Related Problem
 
Similar Threads
Thread
Death of a thread
Sleeping Threads
Thread Priority
Thread Priority Question