• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Deprecated Methods

 
Srikanth Madduri
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Could someone help me with info on methods of Java 1.1 (like suspend(), resume(), stop()....etc.).
In Java 1.2 these methods have been deprecated. Is there a possibility that questions will be asked on these methods? If so, how do we answer the questions?
Thanks
Srikanth
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Srikanth
I would spend the extrat 10 minutes learning what these methods can do for you. I have seen them alot on the pratice exams.
Monty6
 
Srikanth Madduri
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Monty6,
Thanks for the response. Learning them is fine. But the problem persists.......for example...
Q. Which of the following methods change the state of the thread to Waiting. Select all the valid answers.
a. yield();
b. wait();
c. suspend();
d. sleep();
e. stop();
In the above question, we know that b and d are valid in Java 1.2. But c is valid in Java 1.1. So what're the valid answers?
Regards
Srikanth
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q. Which of the following methods change the state of the thread to Waiting.
Select all the valid answers.
a. yield();
b. wait();
c. suspend();
d. sleep();
e. stop();
"In the above question, we know that b and d are valid in Java 1.2. But c is valid in Java 1.1. So what're the valid answers?"
MOST emphatically, d does not put a Thread in a waiting state, it put the Thread in a sleep state - entirely different. The wait state involves a lock on an object, sleep does not and neither does suspend. A wait-ing Thread can have a sleep like time limit but it is not the same thing.
The suspend and resume methods are deprecated because a Thread that has a lock on an object (via synchronized) will keep the lock while it is suspended - a very likely way to lock up the entire JVM.
You may be asked to recognize that a method has been deprecated but you will not be asked to use a deprecated method to solve a programming problem on the test.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic