【发布时间】:2020-07-20 19:42:40
【问题描述】:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author user
*/
class evenCount extends Thread {
public void run(){
for(int i = 2; i >=20; i++)
{
try
{
Thread.sleep(500);
}
catch(Exception e)
{
System.out.println(e);
}
System.out.println(i);
}
}
}
class oddCount extends Thread {
public void run(){
for(int i = 21; i>=31; i++)
{
try
{
Thread.sleep(700);
}
catch(Exception e)
{
System.out.println(e);
}
System.out.println(i);
}
}
}
class mainThread{
public static void main(String args[]){
evenCount even = new evenCount();
oddCount odd = new oddCount();
even.run();
odd.run();
}
}
```````````````````描述````````````````````````
我想找到偶数和奇数,但输出显示如下:
线程“main”中的异常 java.lang.RuntimeException:无法编译的源代码 - 错误的 sym 类型:线程。 在 evenCount.(Thread.java:16) 在 mainThread.main(Thread.java:56) /Users/user/Library/Caches/NetBeans/8.2/executor-sn-ps/run.xml:53:Java 返回:1 构建失败(总时间:0 秒)
有时它显示构建成功但不显示结果(当我使用 Runnable 时)
【问题讨论】:
标签: java