java1.5以前
继承Thread类和实现Runnable接口这两种
java1.5以后,又有了一下线程池创建线程的方法:
ExecutorSerice pool = Executors.newFixedThreadPool(3);
for (int i=0;i<10 ;i++ )
{
pool.execute(new Runnable(){public void run()});
}
Executors.newCachedThreadPool().execute(new Runnable(){public void run()});
Executors.newSingleThreadExecutor().execute(new Runnable(){public void run()}); |