Hi All,<br><br>I'm new bie to thread programming and I need some assistance in understanding few concepts ...<br><br>I have a very simple program which runs a thread and prints a string.<br><br>import threading<br><br>
class MyThread(threading.Thread):<br> def __init__(self, parent = None):<br> threading.Thread.__init__(self)<br> <br> def run(self):<br> print 'Hello World'<br> <br>def main():<br> for i in range(10):<br>
MyThread_Object = MyThread()<br> print 'Object id is : ' , id(MyThread_Object)<br> print 'Staring thread ----------> ' , MyThread_Object.getName()<br> MyThread_Object.start()<br>
count = threading.activeCount()<br> print 'The active thread count is: ' , count<br><br>if __name__ == '__main__':<br> main()<br><br>When I run this, I could see 10 thread being called. But when I print the active thread count it is only 2. <br>
<br>Need some understanding on the following.<br><br>1. How the total active thread is 2?<br>2. how do I stop a thread? does it get automatically stopped after execution ? <br>3. Am I totally wrong in understanding the concepts.<br>
4. what is the difference between active_count() and activeCount() since both seem to give the same result.<br>5. is there a way to find out if the thread is still active or dead?<br><br>Please help me in understanding ..<br clear="all">
<br>-- <br>Vijay Swaminathan<br>