1.实现runnable接口实现功能性解耦

 

package com.test.thread;

public class TestRunnable implements Runnable{

	@Override
	public void run() {
		for (int i = 0; i < 20; i++) {
			System.out.println(Thread.currentThread().getName());
		}
	}

}
package com.test.thread;

public class TestMain {
	public static void main(String[] args) {
		
		TestRunnable runnable_01=new TestRunnable();
		Thread thread=new Thread(runnable_01, "runnable_01");
			
		TestRunnable runnable_02=new TestRunnable();
		Thread thread2=new Thread(runnable_02, "runnable_02");
		
			thread.start();
			thread2.start();
	}
}

Java多线程____一个简单的多线程demo_解耦