Skip to content

Instantly share code, notes, and snippets.

@kanazux
Last active August 29, 2015 14:01
Show Gist options
  • Save kanazux/f21781b59fa3e412ee58 to your computer and use it in GitHub Desktop.
Save kanazux/f21781b59fa3e412ee58 to your computer and use it in GitHub Desktop.
threads no comment
#/usr/local/bin/python
# -*- coding: utf-8 -*-
import threading
import time
class process_one(threading.Thread):
def __init__(self, name, number):
threading.Thread.__init__(self)
self.name = name
self.number = number
def run(self):
for item in range(5):
print "{}\t{}".format(self.name,self.number)
time.sleep(2)
one = process_one('one', 1)
one.start()
def process_two(name, number):
for item in range(10):
print "{}\t{}".format(name,number)
time.sleep(1)
two = threading.Thread(target=process_two, args = ['two', 2])
two.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment