专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > J2SE

in thread "main" java.lang.NoSuchMethodError: main

发布时间:2010-06-05 05:30:35 文章来源:www.iduyao.cn 采编人员:星星草
初级线程异常问题
以下这段代码是哪里出错吗???怎么会出现这种异常呢??
Exception in thread "main" java.lang.NoSuchMethodError: main




class mythread implements Runnable
{
private String name;
private int time;
public mythread(String name,int time){
this.name=name;
this.time=time;
}
public void run(){
try{
Thread.sleep(this.time);
}catch(InterruptedException e){
e.printStackTrace();
}
System.out.println(this.name+"运行,休眠"+this.time+"毫秒");
}
}
public class oo2
{
public static void mian(String args[]){
mythread my1=new mythread("线程A",10000);
mythread my2=new mythread("线程B",20000);
mythread my3=new mythread("线程C",30000);
new Thread(my1).start();
new Thread(my2).start();
new Thread(my3).start();
}
}

------解决方案--------------------
public static void mian(String args[]){

天啊,楼主认真点……main写成mian了
------解决方案--------------------
缺少主方法main

class mythread implements Runnable
{
 private String name;
 private int time;
 public mythread(String name,int time){
 this.name=name;
 this.time=time;
 }
 public void run(){
 try{
 Thread.sleep(this.time);
 }catch(InterruptedException e){
 e.printStackTrace();
 }
 System.out.println(this.name+"运行,休眠"+this.time+"毫秒");
 }
}
public class oo2
{
 public static void main(String args[]){
 mythread my1=new mythread("线程A",10000);
 mythread my2=new mythread("线程B",20000);
 mythread my3=new mythread("线程C",30000);
 new Thread(my1).start();
 new Thread(my2).start();
 new Thread(my3).start();
 }
}

这样试下

public static void main(String args[]) 改下这行 
原来写的mian 当普通的函数编译
 
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: