Skip to content

Instantly share code, notes, and snippets.

@alejolp
Created October 15, 2011 15:48
Show Gist options
  • Save alejolp/1289735 to your computer and use it in GitHub Desktop.
Save alejolp/1289735 to your computer and use it in GitHub Desktop.
>>> def f():
... for x in xrange(10):
... print "Mi thread id: ", thread.get_ident()
... sys.stdout.flush()
... time.sleep(0.1)
...
>>>
>>>
>>> tt = [thread.start_new_thread(f, tuple()) for y in xrange(10)]
Mi thread id: >>> 139873167742720
Mi thread id: Mi thread id: 139873192920832
Mi thread id: Mi thread id: Mi thread id: Mi thread id: Mi thread id: Mi thread id: 139873184528128139873176135424 139873142564608Mi thread id:
139873150957312
139873201313536139873159350016
139873125779200
139873134171904
Mi thread id: 139873150957312
Mi thread id: 139873192920832
Mi thread id: 139873201313536
Mi thread id: Mi thread id: 139873142564608Mi thread id: 139873125779200
Mi thread id: 139873167742720
Mi thread id: 139873134171904Mi thread id:
139873176135424
Mi thread id: 139873159350016
139873184528128
Mi thread id: 139873150957312
Mi thread id: 139873192920832
Mi thread id: 139873125779200
Mi thread id: 139873201313536
Mi thread id: 139873167742720
Mi thread id: Mi thread id: Mi thread id: Mi thread id: 139873176135424Mi thread id: 139873184528128
139873134171904139873159350016
139873142564608
Mi thread id: 139873150957312
Mi thread id: 139873192920832
Mi thread id: 139873125779200
Mi thread id: 139873201313536
Mi thread id: 139873167742720
Mi thread id: 139873134171904
Mi thread id: Mi thread id: Mi thread id: Mi thread id: 139873159350016 139873184528128139873142564608
139873176135424
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment