[Tutor] How to use threads ?

Gwyn Evans gwyn.evans at gmail.com
Thu Mar 3 17:36:05 CET 2005


On Thu, 3 Mar 2005 17:53:11 +0200, Mark Kels <mark.kels at gmail.com> wrote:
> On Thu, 3 Mar 2005 14:31:55 +0000, Gwyn Evans <gwyn.evans at gmail.com> wrote:
> > Hi,
> >   The one thing that stands out is that when you subclass Thread as
> > you do, you need to override the 'run' method, which will get called
> > as a result of you calling 'start()'.
> >   You're calling start(), but you've not got a run method, so the new
> > thread doesn't call your code.  Instead you've got your own call to
> > 'scanner()', that is running under the main thread.
> >
> >   Rename 'scanner()' to 'run()', remove the call to 'scanner()' and
> > see how that looks.
> 
> It looks the same, but with 1 line less...
> The thread is still working after the loop is done, so after I stop
> the scan I cant start another one.

  Hmm, at this point I'd be either firing up a debugger or adding a
print/msg box to check that it's exiting run() as expected...

  How are you trying to start another scan?  You'd have to create a
new instance, you can't just call app.start() again.

/Gwyn


More information about the Tutor mailing list