---
title: "使用Runnable实现多线程"
author: "1140566087"
date: "2013-04-16T11:25:23Z"
tags: []
categories: ["移动开发"]
slug: "runnable"
draft: false
lastmod: "2013-04-16T11:25:23Z"
id: 1848119
url: "https://sunzone.iteye.com/blog/1848119"
---

```java
import java.util.Date;


//Runnable 接口实现多线程
public class  Thread_RunnableTest implements Runnable {

	private int pauseTime;
	private String Threadname;
	public Thread_RunnableTest(int x,String y){
		this.pauseTime = x;
		this.Threadname = y;
	}

	
	public void run() {
		// TODO Auto-generated method stub
		for(int i=0;i<10;i++){
			try {
				System.out.println(Threadname+":"+new Date(System.currentTimeMillis()));
				Thread.sleep(pauseTime);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		


	}

	//测试线程
	public static void main(String[] args){
		//创建线程 1  
		Thread t1 = new Thread(new Thread_RunnableTest(1000,"我是1线程"));
		t1.start();

		//创建线程 2 
		Thread t2 = new Thread(new Thread_RunnableTest(5000,"我是2线程"));
		t2.start();
	}

}

```