标签:
package text; /** * 多线程 * @author admin * */ public class Threads { public static void main(String[] args){ Thread_1 t1=new Thread_1(); Thread thread1 =new Thread(t1); thread1.start(); Thread_2 t2 =new Thread_2(); Thread thread2=new Thread(t2); thread2.start(); } } class Thread_1 implements Runnable{ public void run() { try { //线程暂停一秒 Thread.sleep(1000); //此方法只是为了更直接的看到线程效果而添加 System.out.println("执行方法1"); } catch (InterruptedException e) { e.printStackTrace(); } } } class Thread_2 implements Runnable{ public void run() { try { Thread.sleep(1000); System.out.println("执行方法2"); } catch (InterruptedException e) { e.printStackTrace(); } } }
标签:
原文地址:http://www.cnblogs.com/angto64/p/5126585.html