Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

deprecated method stop()

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everbody,
In the following code depricated function stop() is used.

public class Q1 extends Thread
{
public void run()
{
System.out.println("Before start method");
this.stop();
System.out.println("After stop method");
}
public static void main(String[] args)
{
Q1 a = new Q1();
a.start();
}
}

So if such type of question comes in exam what should be the output:
1. program uses a deprecated method
or
2.prints "Before start method
Thanks in advance
Shikhar
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by shikhar:
Hi everbody,
In the following code depricated function stop() is used.

public class Q1 extends Thread
{
public void run()
{
System.out.println("Before start method");
this.stop();
System.out.println("After stop method");
}
public static void main(String[] args)
{
Q1 a = new Q1();
a.start();
}
}

So if such type of question comes in exam what should be the output:
1. program uses a deprecated method
or
2.prints "Before start method
Thanks in advance
Shikhar

1 and 2. You can compile and run a program with deprecated methods! You get a deprecation warning at compile time but, this is a watning only! The program will still run.
Sun deprecates things for a lot of reasons. In most cases they either have a new method in the same or another class to replace it or (as in the case of stop()) a safe work around. These are still valid methods to allow backward compatability so old code doesn't have to be changed imediately but, be warned... They will remove it in a future release.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have not heard of anybody getting a question that involved figuring out what code using a deprecated method would do when run. If anybody does, I would love to hear about it.
You may be expected to know that stop is deprecated, and it would enhance your general knowledge of Threads to know why stop, suspend, and resume are all deprecated.
Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic