aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes help me.............. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "help me.............." Watch "help me.............." New topic
Author

help me..............

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944

Are they real exam question???
I am sorry really ,but i don't knw that,
and i get it from: http://www.deping.net/cgi-bin/lbbs/topic.cgi?forum=4&topic=436
------------------

[This message has been edited by Lhy Killers (edited July 19, 2001).]
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Why no one help me to solve the examination question???
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
Originally posted by Lhy Killers:
Why no one help me to solve the examination question???

Because you didn't even wait two hours for an answer!!
On your first question:
The two that can't directly stop a thread from executing are notify and notifyAll. Of the others:
Yield will at least temporalily halt the thread, it may be restarted right away by the scheduler. wait will cause the thread to wait until it receives a notify or notifyAll. And if the thread is already running then calling start on it will throw an IllegalThreadStateException.
notify and notifyAll can not directly cause the thread to stop, but if the thread calling them doesn't have the lock on an object they'll throw an IllegalMonitorStateException when the try to call one of those two.
Given the way the question is worded it may have been done better or given little more info.
Hope that helps
Dave


Dave
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Why not select 5>???
The NO.5 directly cause a thread to stop executing?
Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
Originally posted by Lhy Killers:
Why not select 5>???
The NO.5 directly cause a thread to stop executing?

start() CAN stop the current thread from executing.When you start a thread you request the ThreadScheduler to start another lightweight process.Although it seems to us that the ThreadScheduler runs many Threads in parallel, actually one Thread is run at a time.Hence the ThreadScheduler has to stop one Thread to execute another.The time for execution would be so small that we feel that many threads are running simultaneously.
Hope this helps,
Sandeep
SCJP2, OCSD (JDeveloper), OCED(Oracle Internet Platform)
[This message has been edited by Desai Sandeep (edited July 19, 2001).]


<b>Sandeep</b> <br /> <br /><b>Sun Certified Programmer for Java 2 Platform</b><br /> <br /><b>Oracle Certified Solution Developer - JDeveloper</b><br /><b>-- Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java </b><br /><b>-- Object-Oriented Analysis and Design with UML</b><br /> <br /><b>Oracle Certified Enterprise Developer - Oracle Internet Platform</b><br /><b>-- Enterprise Connectivity with J2EE </b><br /><b>-- Enterprise Development on the Oracle Internet Platform </b>
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
desai
Is right I didn't read the answer for #5 completely. It says calling start on another object. And it is correct calling start on another object will not directly cause the current thread to stop. I thought it said if you call it on the currently running thread. That's what I get
Dave
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
But there are two correct answers ,not three,
how could i select which two???
Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
Hi,
The question is about what CANNOT stop; not what CAN!The Thread.start() CAN!
So the answers are 3 (notify) and 4(notifyAll)
-- Sandeep
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
I would be inclined to say that calling start on another object cannot directly cause a thread to stop. Even if the thread has a higher priority it is system dependent and it may or may not cause the current thread to stop.
I think it is a poorly worded question. When they say 'cause a thread to stop' I am assuming they mean the currently executing thread. On answers 1 - 4 I assume they mean they current object. I know its dangerous to assume but...
So, calling start on another object would also be a valid answer.
Anyone else have an opinion or the definitive answer??

Dave
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I am puzzled about that..
Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
Dave,
We know one thing for sure that when you call the Thread.start() method, you are passing the control to Thread scheduler.Also we know the way the Thread scheduler functions - i.e, it executes one thread at a shortest possible time, giving us a picture that the two threads ae executing simultaneously.
Instead of making the assumption that the question is asking you whether "the current thread" stops, we can talk in generic terms - one of the threads (which is already started) will get effected; i.e, either the thread that has been started has to STOP from running or the Thread that is been running is stopped by the Thread scheduler to allow the new started thread to run.So, in either case Thread.start() CAN stop a thread from executing.
Hope this helps,
Sandeep
[This message has been edited by Desai Sandeep (edited July 20, 2001).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: help me..............