正在加载图片...
主线程示例 class Mythread extends Thread i public static void main( string args获得当前线程, Thread t= Thread currentThread oi 庄线程 System. out. print1n("当前线程是:"+t) t setName("MyJavaThread")i 改变线程的 内部名称 System. out. println("当前线程名是:"+t); try t for(int i=0;1<3; 1++)i System. out. println (i)i Thread. sleep(1500)i 输出每个数后 暂停1500喜 命令提示 catch(InterruptedExceptiof vaeapiava Mythread System.out, print1n("主线线准是:mws Java> Designed by Chiyong, C20058 Designed by Chiyong,©2005 主线程示例 class Mythread extends Thread { public static void main(String args[]) { Thread t= Thread.currentThread(); System.out.println("当前线程是: "+t); t.setName("MyJavaThread"); System.out.println("当前线程名是: "+t); try { for(int i=0;i<3;i++) { System.out.println(i); Thread.sleep(1500); } } catch(InterruptedException e) { System.out.println("主线程被中断"); } } } 获得当前线程, 即主线程 改变线程的 内部名称 输出每个数后 暂停1500毫 秒
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有