package com;

public class Demo {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        
        //方法1
        Thread t = new Thread() {
            public void run() {
                for (int i = 1; i <= 5; i++) {
                    System.out.print(i + " ");
                }
            }
        };
        t.start();
        System.out.print("\r\n");
        //方法2
        
        Runnable r = new Runnable() {
            public void run() {
                for (int i = 1; i <= 5; i++) {
                    System.out.print(i + " ");
                }
            }
        };
        Thread t1 = new Thread(r);
        t1.start();

    }
    


}

 

相关文章:

  • 2021-12-15
  • 2021-08-21
  • 2021-06-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-10
  • 2021-08-09
猜你喜欢
  • 2021-04-06
  • 2021-11-08
  • 2022-03-07
  • 2021-09-24
  • 2022-02-09
  • 2021-07-25
相关资源
相似解决方案