Software Design
Spring 2007

Lab Exercise 10

Now run it. When you press the Make Threader button, it
creates a Threader (which is a kind of Turtle). The Threader
executes snowflake, which runs for a while, drawing a
Koch snowflake.

While the Threader is making the rounds, try pressing
Run this code. Is the GUI responsive while snowflake
is running? What does this tell you about the way the GUI is
implemented in Tkinter?

While the Threader is hard at work, press the Quit button.
Does the program quit right away? Why not? Try hitting Control-C
while it is running.

While one Threader is hard at work, press the Make Threader
button and see what happens. Can you explain what you see?

Change make_threader so that when it invokes snowflake,
it runs in a new Thread. Now run more than one Threader at a time.
See the difference? Do all the Threaders run at the same speed?
Why or why not?

Unfortunately, you still can't quit while a Threader is
running. To fix that:

Add an attribute named running to Threader, and
initialize it to 1.

Change koch so that it checks running
and quits if it is 0.

Create a new kind of TurtleWorld called ThreaderWorld.
Override quit so that when the user presses quit, it
loops through all the Threaders and sets their running
attribute to 0.

It ain't pretty, but unfortunately you can't really kill another
thread; you have to ask it to kill itself.