Threading in Python

Recently I implemented threading in my flamesgame app. The steps I took to implement threading are:

First I import the threading library:

import threading

Then I created a class for the thread:

class PostToFacebook(threading.Thread):
     def __init__(self, message):
          self.message = message

     def run(self):
, self.message)

Here PostToFacebook is the class which I used for the Threading. And the code to create the thread is:

PostToFacebook("message to facebook").start()

This will invoke the __init__() method, where it set the message value and invoke the run() method which post message to the facebook.

blog comments powered by Disqus
Pomodoro Technique >>
<< unittest - Unit Testing fra...