pausing a thread

Alex Martelli aleaxit at yahoo.com
Thu Jul 5 06:26:25 EDT 2001


"Daniel Nuriyev" <danielnuriyev at yahoo.com> wrote in message
news:3d8d3c0.0107050135.ff84ead at posting.google.com...
> Hello
> This is a Java programmer's question
> How do you say:
> class QQQ extends Thread{
>     public void run(){
>         ...
>         sleep(ms);
>     }
> }
> in Python? Thank you all.

import threading, time

class QQQ(threading.Thread):
    def run(self):
        # ... whatever else you wish ...
        time.sleep(ms/1000.0)

time.sleep uses seconds as its unit of measure,
whence the /1000.0 part assuming ms stands for
'milliseconds'.  (Note the argument is a float,
so fractions of a second are OK, but you do have
to use seconds as the UNIT of measure here).


Alex






More information about the Python-list mailing list