---
title: "Python多线程实例"
author: "rokuan"
date: "2011-07-26T22:00:59Z"
tags: []
categories: ["编程语言"]
slug: "python"
draft: false
lastmod: "2011-07-26T22:00:59Z"
id: 1133450
url: "https://rokuan.iteye.com/blog/1133450"
---

```python

from threading import Thread
class Task(Thread):
    def __init__(self, count):
        super(Task, self).__init__()
        #Thread.__init__(self)
        self.count = count
    def run(self):
        for i in range(10):
            print 'Task' + str(self.count) + ':' + str(i)
            
if __name__ == '__main__':
    for i in range(10):
        Task(i+1).start()

```