Hi, all:
Something I am not sure about the question:
If you have an applicaton which execute the following codes:
Thread myT=new Thread();
myT.start();
Select all of the following statements that are correct:
[a]. The Thread myT is now in a runnable state.
[b]. The Thread myT has the NORM_PRIORITY priority.
[c]. The Thread will die without accemplishing anything
[d]. The run method in the class where the statement occurs will be executed.
---Anwser is [a],[c]
Try the following codes:
class
test {
public static void main(
String argv[]){
Thread t=new Thread();
t.start();
System.out.println(t.getPriority());
System.out.println(t.isAlive() );
}
}
Output:
5
true
About option [a]. right with no doubts.
Q1: About option [b]. Default priority is 5 which will set to the new threads,right?
Q2: About option [c], The run method in the Thread class will be executed. The run method in the Thread class is empty so myT will die as soon as it runs. But the above codes show it is still alive after it runs!! why?
Q3: Also wanna know the explanation about optin [d]?
help! thanks!