文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>线程、静态、构造函数

线程、静态、构造函数

时间:2010-11-01  来源:铨铨灰

public class Thread1 implements Runnable {  
    public Thread1() {  
        System.out.println("constructor");  
    }  
      
    public static void s(){  
        System.out.println("static function");  
    }  
      
    static {//静态代码块;  
        System.out.println("static  ...");  
    }  
    public void run() {  
        System.out.println(Thread.currentThread().getName()+":run");  
    }  
      
    public static void main(String []args){  
        Thread1.s();//静态方法可以通过//类名.方法//来调用  
        Thread1 t1 = new Thread1();  
        Thread t = new Thread(t1);  
        t.run();//主函数main调用方法run()  
        t.start();//线程t开始  
    }  
}  
/* 
 * 输出结果为: 
 * static 
 * constructor 
 * main:run 
 * Thread-0:run 
 */  
相关阅读 更多 +
排行榜 更多 +
哥布林弹球b服手游下载

哥布林弹球b服手游下载

休闲益智 下载
小马样式盒游戏下载

小马样式盒游戏下载

休闲益智 下载
异变小镇中文版下载安装

异变小镇中文版下载安装

冒险解谜 下载