import java.io.*;
import java.lang.Runnable;
import java.lang.Thread;
class First extends Thread
{
public void run()
{
try
{
this.suspend();
System.out.println("the first thread");
}
catch(Exception e)
{
System.out.println("the first thread has a exception");
}
}
}class Second extends Thread
{
public void run()
{
try
{
System.out.println("the second thread");
}
catch(Exception e)
{
System.out.println("the second thread has a exception");
}
}
}
public class ThreeThreads
{
public static void main(String[] args)
{
First first = new First();
Second second = new Second();
Thread.yield();
}
}编译提示我覆写或是调用了过时的api??我就是想这3个thread循序执行~!
import java.lang.Runnable;
import java.lang.Thread;
class First extends Thread
{
public void run()
{
try
{
this.suspend();
System.out.println("the first thread");
}
catch(Exception e)
{
System.out.println("the first thread has a exception");
}
}
}class Second extends Thread
{
public void run()
{
try
{
System.out.println("the second thread");
}
catch(Exception e)
{
System.out.println("the second thread has a exception");
}
}
}
public class ThreeThreads
{
public static void main(String[] args)
{
First first = new First();
Second second = new Second();
Thread.yield();
}
}编译提示我覆写或是调用了过时的api??我就是想这3个thread循序执行~!
解决方案 »
- 求结合多硬件的javaSE解决方案
- 怎样用正则表达式判断是否为数字??
- 向高手求教:在java程序中如何使用外部命令(如java命令)执行已编译好了的java程序,并且希望能够输入数据和输出数据
- 有关java中使用正则表达式的问题(不好意思分数就剩下10了)
- 为什么我这个问题贴发了这么多一个回复都没有呢?CSDN上的高手哪去了啊?
- 请教?
- jce 求助
- 两个Java文件在一个JVM中,可否访问同一个动态链接库?
- 如何学好JBuileder,从JAVA看起还是直接来?能否推荐一本好的JBuilder书?这厢有礼了。
- 向数据库插入日期问题
- java数据库的问题,大家帮忙看看,有分加哦!
- 在FIREFOX浏览器中显示toolbar的时候,如何用JAVA语言把toolbar上显示的图片的底色设置为透明?
main函数中创建对象后调用其方法就可以了,我已经调试过。
public static void main(String[] args) {
// TODO Auto-generated method stub
First first = new First();
first.run();
Second second = new Second();
second.run();
Thread.yield();
}