Chinaunix首页 | 论坛 | 博客
  • 博客访问: 268640
  • 博文数量: 103
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 705
  • 用 户 组: 普通用户
  • 注册时间: 2013-05-02 16:15
文章分类

全部博文(103)

文章存档

2014年(8)

2013年(95)

我的朋友

分类: Python/Ruby

2013-12-18 23:22:40

import threading
import time
class ThreadTest(threading.Thread):
        def __init__(self,index,create_time):
                threading.Thread.__init__(self)

                self.index = index
                self.create_time = create_time

        def run(self):
                time.sleep(1)
                print time.time() - self.create_time,"\t",self.index
                print "Thread %d exit...."%(self.index)
threads=[]
for index in range(5):
        thread = ThreadTest(index,time.time())
        thread.start()
        threads.append(thread)
for thread in threads:
        thread.join()
print "Main Thread exit...."

阅读(830) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~