MyException - 我的异常网
当前位置:我的异常网» J2SE » in thread "main" java.lang.NoSuchMetho

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

www.myexceptions.net  网友分享于:2013-11-11  浏览:382次
初级线程异常问题
以下这段代码是哪里出错吗???怎么会出现这种异常呢??
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 当普通的函数编译
 

文章评论

软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有