[source code] Python Programming Tutorial - 34 - threading

+1 Bucky Roberts · September 23, 2014

import threading

class BuckysThread(threading.Thread):
   def run(self):
       for _ in range(10):

# you can give each thread a name property by default
x = BuckysThread(name='Sending out messages')  
y = BuckysThread(name='Listening for messages')
x.start()  # creates a thread and calls run()
y.start()  # right after it starts x, it moves on to something else

Post a Reply


Oldest  Newest  Rating
+2 Wojciech Lecki · September 24, 2014
Thank you so much for the source code here - it is so much easier to get back to the specific tutorial later :)

P.S. Please don't leave the Python language tutorials at the middle of nowhere, even though it is not the most popular tutorial series! It's definitely the best programming language I've learned with you.
0 Programmer VB · October 28, 2014
I am getting an error when i import threading.
What should i do?
Please help
  • 1



This section is all about snakes! Just kidding.

Bucky Roberts Administrator