www.digitalmars.com         C & C++   DMDScript  

D - ???

reply "Phill" <phill pacific.net.au> writes:
What is the  reason for a Thread not to
call wait(int) on itself?

for example:

Thread t1;
t1 = Thread.getThis();

for(int i = 0; i < count; i ++){
        doSomthing(i);
        t1.wait(1000); // why is it not good to use it in this manner?
        }

me again.
Feb 05 2004
parent reply "Walter" <walter digitalmars.com> writes:
I don't know of a reason why.

"Phill" <phill pacific.net.au> wrote in message
news:bvuv82$1rl0$1 digitaldaemon.com...
 What is the  reason for a Thread not to
 call wait(int) on itself?

 for example:

 Thread t1;
 t1 = Thread.getThis();

 for(int i = 0; i < count; i ++){
         doSomthing(i);
         t1.wait(1000); // why is it not good to use it in this manner?
         }

 me again.
Feb 06 2004
parent reply "Phill" <phill pacific.net.au> writes:
"Walter" <walter digitalmars.com> wrote in message
news:bvvqh9$6np$1 digitaldaemon.com...
 I don't know of a reason why.
Sorry for not being clear, but I meant why does that piece of code cause this error at runtime? Error: Thread error: wait on self Phill.
 "Phill" <phill pacific.net.au> wrote in message
 news:bvuv82$1rl0$1 digitaldaemon.com...
 What is the  reason for a Thread not to
 call wait(int) on itself?

 for example:

 Thread t1;
 t1 = Thread.getThis();

 for(int i = 0; i < count; i ++){
         doSomthing(i);
         t1.wait(1000); // why is it not good to use it in this manner?
         }

 me again.
Feb 07 2004
parent reply "Phill" <phill pacific.net.au> writes:
I can see that it is calling wait on itself, but
why is a Thread calling wait on itself a bad thing
to do?
I thought wait(milliseconds) would have been
the equivilent of the Java method
Thread.sleep(milliseconds)
Am I wrong?


"Phill" <phill pacific.net.au> wrote in message
news:c01vhr$v67$1 digitaldaemon.com...
 "Walter" <walter digitalmars.com> wrote in message
 news:bvvqh9$6np$1 digitaldaemon.com...
 I don't know of a reason why.
Sorry for not being clear, but I meant why does that piece of code cause this error at runtime? Error: Thread error: wait on self Phill.
 "Phill" <phill pacific.net.au> wrote in message
 news:bvuv82$1rl0$1 digitaldaemon.com...
 What is the  reason for a Thread not to
 call wait(int) on itself?

 for example:

 Thread t1;
 t1 = Thread.getThis();

 for(int i = 0; i < count; i ++){
         doSomthing(i);
         t1.wait(1000); // why is it not good to use it in this manner?
         }

 me again.
Feb 07 2004
parent reply "Walter" <walter digitalmars.com> writes:
Ah, I see. wait() is for waiting for another thread. To wait on the current
thread, use std.c.time.sleep

"Phill" <phill pacific.net.au> wrote in message
news:c01vmj$ver$1 digitaldaemon.com...
 I can see that it is calling wait on itself, but
 why is a Thread calling wait on itself a bad thing
 to do?
 I thought wait(milliseconds) would have been
 the equivilent of the Java method
 Thread.sleep(milliseconds)
 Am I wrong?


 "Phill" <phill pacific.net.au> wrote in message
 news:c01vhr$v67$1 digitaldaemon.com...
 "Walter" <walter digitalmars.com> wrote in message
 news:bvvqh9$6np$1 digitaldaemon.com...
 I don't know of a reason why.
Sorry for not being clear, but I meant why does that piece of code cause this error at runtime? Error: Thread error: wait on self Phill.
 "Phill" <phill pacific.net.au> wrote in message
 news:bvuv82$1rl0$1 digitaldaemon.com...
 What is the  reason for a Thread not to
 call wait(int) on itself?

 for example:

 Thread t1;
 t1 = Thread.getThis();

 for(int i = 0; i < count; i ++){
         doSomthing(i);
         t1.wait(1000); // why is it not good to use it in this
manner?
         }

 me again.
Feb 07 2004
next sibling parent "Phill" <phill pacific.net.au> writes:
Oh I see (said the blind man)

Thanks!

Phill.


"Walter" <walter digitalmars.com> wrote in message
news:c02erl$26ar$1 digitaldaemon.com...
 Ah, I see. wait() is for waiting for another thread. To wait on the
current
 thread, use std.c.time.sleep

 "Phill" <phill pacific.net.au> wrote in message
 news:c01vmj$ver$1 digitaldaemon.com...
 I can see that it is calling wait on itself, but
 why is a Thread calling wait on itself a bad thing
 to do?
 I thought wait(milliseconds) would have been
 the equivilent of the Java method
 Thread.sleep(milliseconds)
 Am I wrong?


 "Phill" <phill pacific.net.au> wrote in message
 news:c01vhr$v67$1 digitaldaemon.com...
 "Walter" <walter digitalmars.com> wrote in message
 news:bvvqh9$6np$1 digitaldaemon.com...
 I don't know of a reason why.
Sorry for not being clear, but I meant why does that piece of code cause this error at runtime? Error: Thread error: wait on self Phill.
 "Phill" <phill pacific.net.au> wrote in message
 news:bvuv82$1rl0$1 digitaldaemon.com...
 What is the  reason for a Thread not to
 call wait(int) on itself?

 for example:

 Thread t1;
 t1 = Thread.getThis();

 for(int i = 0; i < count; i ++){
         doSomthing(i);
         t1.wait(1000); // why is it not good to use it in this
manner?
         }

 me again.
Feb 07 2004
prev sibling parent "Phill" <phill pacific.net.au> writes:
msleep(uint) does the trick.

Thanks.


"Walter" <walter digitalmars.com> wrote in message
news:c02erl$26ar$1 digitaldaemon.com...
 Ah, I see. wait() is for waiting for another thread. To wait on the
current
 thread, use std.c.time.sleep

 "Phill" <phill pacific.net.au> wrote in message
 news:c01vmj$ver$1 digitaldaemon.com...
 I can see that it is calling wait on itself, but
 why is a Thread calling wait on itself a bad thing
 to do?
 I thought wait(milliseconds) would have been
 the equivilent of the Java method
 Thread.sleep(milliseconds)
 Am I wrong?


 "Phill" <phill pacific.net.au> wrote in message
 news:c01vhr$v67$1 digitaldaemon.com...
 "Walter" <walter digitalmars.com> wrote in message
 news:bvvqh9$6np$1 digitaldaemon.com...
 I don't know of a reason why.
Sorry for not being clear, but I meant why does that piece of code cause this error at runtime? Error: Thread error: wait on self Phill.
 "Phill" <phill pacific.net.au> wrote in message
 news:bvuv82$1rl0$1 digitaldaemon.com...
 What is the  reason for a Thread not to
 call wait(int) on itself?

 for example:

 Thread t1;
 t1 = Thread.getThis();

 for(int i = 0; i < count; i ++){
         doSomthing(i);
         t1.wait(1000); // why is it not good to use it in this
manner?
         }

 me again.
Feb 07 2004