Linux Today: Linux News On Internet Time.
Search Linux Today
Linux News Sections:  Developer -  High Performance -  Infrastructure -  IT Management -  Security -  Storage -
Linux Today Navigation
LT Home
Link to Us
Linux Jobs

More on LinuxToday

Python Threads and Queues

Aug 12, 2009, 06:02 (1 Talkback[s])

"Each thread is still counting. but the sleep() allowed each thread time to take control and execute. Therefore now the output is interleaved, with each thread having a turn.

"Notice that PROGRAM ENDING is printing out at the beginning rather than the end. This is because the main loop is executing faster than the threads can start running. If there are things which you need to do after a thread or threads have completed, then you can use join() to block until the completion of a thread. If we uncomment the join() statement we get:"

Complete Story

Related Stories: