解决方案 »

  1.   

    public static void manin(String args[])
    改为
    public static void main(String args[])
      

  2.   


    package demo.spli;public class ThreadTerminate {
        public static void main(String args[])throws Exception{//楼主把main方法写错了
         int i=0;
         Hello h=new Hello();
         Thread t =new Thread(h);
         t.setPriority(Thread.MAX_PRIORITY);
         t.start();
         System.out.println("Please stop");
         h.stopRunning();
         while(i<5){
          System.out.println("Good Morning"+i++);
         }
        }
    }class Hello implements Runnable{
    int i=0;
    private boolean timeToQuit=false;
    public void run(){
    while(!timeToQuit){
    System.out.println("Holle"+i++);
    try{
    if(i%2==0)
    Thread.sleep(10);
    }catch(Exception e){}
    }
    }
    public void stopRunning(){
    timeToQuit=true;
    }
    }