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


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

Thread

suren r
Greenhorn

Joined: Sep 01, 2000
Posts: 7
Hi ,
I am new to Java programming,I need help from you guys..
I saw this question in mock exam and I though the answer is
"starting" and "done",but it's printing only"starrting"..where as if I replace yield()in place of suspend()it is printing both..
I remember reading some where suspended threads canbe restarted..
if that is the case why it is not printing both words..
Thanks in advance.....
here is the program
class demo1 extends Thread {
public void run( ) {
System.out.println("Starting");
suspend( );
resume( );
System.out.println("Done");
}
public static void main(String args[ ]) {
demo1 tt = new demo1( );
tt.start( );
}
}
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12683
    
    5
When your demo1 Thread executes suspend, it suspends itself.
There exists no running Thread to execute resume so it stays suspended indefinately.
Both suspend and resume are deprecated methods of Thread. You should not be using them because they can easily lead to deadlock situations.
Bill

Java Resources at www.wbrogden.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Thread
 
Similar Threads
A Question for beginners - 2
About static method
A question for All
Static method modifier question
constructor