package demo0;import java.util.concurrent.Callable;import java.util.concurrent.ExecutorService;import java.util.concurrent.Executors;import org.junit.Test;class Thread1 extends Thread { @Override public void run() { System.out.println("thread1...."); }}class Thread2 implements Runnable { @Override public void run() { System.out.println("thread2...."); }}class Thread3 implements Callable{ @Override public String call() throws Exception { System.out.println("thread3...."); return null; }}/** * Java创建多线程的方法 * @author mengfeiyang * */public class ThreadCreate { @Test public void test004(){ new Thread(){ public void run(){ System.out.println("thread4..."); } }.start(); } @Test public void test005(){ new Thread(new Runnable(){ @Override public void run() { System.out.println("thread5..."); } }).start(); } @Test public void test006(){ Thread t6 = new Thread(new Runnable(){ @Override public void run() { System.out.println("thread6..."); } }); t6.start(); } @Test public void test007(){ Thread t7 = new Thread(new Thread2()); t7.start(); } @Test public void test008(){ ExecutorService es = Executors.newSingleThreadExecutor(); es.submit(new Thread3()); es.execute(new Thread1()); } }