Java多线程操作<一>

Example <一>:

/**
 *
 */

/**
 * @author Administrator
 *
 */
public class MultiThread {

 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  MyThread NewThread=new MyThread();
  new Thread(NewThread.getthread()).start();
  
  //NewThread.setPriority(Thread.MAX_PRIORITY);
  //NewThread.setDaemon(true);//后台线程
  //NewThread.start();
  //while(true)
  System.out.println("current thread : " + Thread.currentThread().getName());
 }

}


public class MyThread {//implements Runnable{//extends Thread{
 
 int index=0;
 private class InnerThread extends Thread{//内部类
  public void run(){
   System.out.println("current thread : " + Thread.currentThread().getName()+index++);
  }
 }
 Thread getthread(){
  return new InnerThread();
 }
 /*
 public void run(){
  //while(true){
  System.out.println("current thread : " + Thread.currentThread().getName()+index++);
  //yield();
  //}
 }*/
 
}

 

posted @ 2013-07-24 13:34  MMLoveMeMM  阅读(133)  评论(0编辑  收藏  举报