知识
助手
最大化  清空记录  历史记录
   2061  
查询码: 00000328
java启动线程三种方式
作者: 系统管理员 于 2017年11月09日 发布在分类 / 二次开发 / 后台 ,于 2017年11月09日 编辑
线程 thread


1.继承Thread

public class java_thread extends Thread{
	public static void main(String args[])
	{
		(new java_thread()).run();
		System.out.println("main thread run ");
	}
	public synchronized void run()
	{
		System.out.println("sub thread run ");
	}

}

2.实现Runnable接口

public class java_thread implements Runnable{
	public static void main(String args[])
	{
		(new Thread(new java_thread())).start();
		System.out.println("main thread run ");
	}
	public void run()
	{
		System.out.println("sub thread run ");
	}

}

3.直接在函数体使用

void java_thread()
{

   Thread t = new Thread(new Runnable(){
      public void run(){
      mSoundPoolMap.put(index, mSoundPool.load(filePath, index));
      getThis().LoadMediaComplete();
      }});
		t.start();
}

0人参与


 历史版本

修改日期 修改人 备注
2017-11-09 09:59:31[当前版本] 系统管理员 修改格式
2017-11-09 09:58:47 系统管理员 修改格式
2017-11-09 09:58:09 系统管理员 CREAT

  目录
    wcp知识库系统-京ICP备15024440号-1 -V 5.1.3 -wcp