Friday, April 15, 2016

thread in python

http://www.tutorialspoint.com/python/python_multithreading.htm

http://opensourceforu.com/2011/01/python-threading-and-its-caveats/

Simple thread example:

#!/usr/bin/env python
from threading import Thread
class mythread(Thread):
       def __init__(self):
               Thread.__init__(self)   # Must initialize the thread

       def run(self):           # Must override the run method of Thread Class
            test_function()

def test_function():
    print 'NOT OK'

th1 = mythread()
th1.start()

th1.join()
print 'Done'

No comments:

Post a Comment