I beleive there are no daemon thread questions on the new Oracle exam.
Thanks,
Mark
About Question com.enthuware.ets.scjp.v6.2.553 :
Moderator: admin
-
- Posts: 9
- Joined: Sat Feb 25, 2012 3:51 pm
- Contact:
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.553 :
Yes, theoretically they have been removed from the objectives but some candidates have reported seeing them on the exam. So we have kept a couple (I think there are only 2 questions) about it in the question bank, just to make sure there are no surprises.
HTH,
Paul.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 2
- Joined: Sun Jan 06, 2013 9:38 am
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.553 :
I guess these two options (marked as correct) are contradict each other:
A program ends when all non-daemon threads end.
Second option sounds likeA program ends when all threads end.
And regarding this explanationA program ends when all threads (non-daemon and daemon) end.
Could you please show me how can I stop for sure any thread (non-daemon and daemon)?You can stop any thread.
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.553 :
A program ends when all non-daemon threads end. All threads includes daemon and non daemon threads. Therefore, if all threads end, the program will end. But I see what you are saying. It may also imply that a program does not end until all threads end, which is not true.
The option "You can stop any threads" refers to any daemon or non-daemon thread and that there is no restriction as to which thread you can stop and which you cannot. Of course, if a thread is waiting on a socket connection, you may not be able to "stop" it but that is not an issue with thread but the socket. Other than that, the following code shows how you can stop a thread for sure:
Note that stop method is deprecated but nonetheless it is available.
HTH,
Paul.
The option "You can stop any threads" refers to any daemon or non-daemon thread and that there is no restriction as to which thread you can stop and which you cannot. Of course, if a thread is waiting on a socket connection, you may not be able to "stop" it but that is not an issue with thread but the socket. Other than that, the following code shows how you can stop a thread for sure:
Code: Select all
public class Test {
static Thread t;
public static void main(String[] args) throws Exception{
t = new Thread(){
public void run(){
for(;;){
System.out.println("in thread");
}
}
};
t.start();
Thread.sleep(1000);
t.stop();
}
}
}
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 215 guests