Software Design Lecture Notes Fall 2004 For Friday, prepare for the exam. For Monday, work on your project. Exam questions? Threading --------- A thread is an object that can execute a program. In UNIX, when you launch a program from the shell, it creates one thread that executes the program. If you want additional threads, you have to create them yourself. Here's the standard idiom: thread = Thread(target=loop, args=[string.lowercase, 0.4]) thread.start() But it's so ugly it begs to be encapsulated: def run_in_thread(function, *args, **kwargs): thread = Thread(target=function, args=args, kwargs=kwargs) thread.start() return thread run_in_thread(loop, string.lowercase, 0.4)