[CentralOH] Python threads

Steven Huwig steven_h at acm.org
Mon Aug 4 20:23:33 CEST 2008

Your global counter is the problem. You should give the thread its own
number before you start the thread.

import threading
import time
import random

class MyThread ( threading.Thread ):
  def __init__(self, num):
      self.num = num

  def run ( self ):
     print 'This is thread ' + str ( self.num ) + ' speaking.'
     print 'Hello and good bye.'

for x in xrange ( 20 ):

More information about the CentralOH mailing list