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(); } }
时间: 2024-10-15 23:58:09