Thread overview
???
Feb 06, 2004
Phill
Feb 06, 2004
Walter
Feb 07, 2004
Phill
Feb 07, 2004
Phill
Feb 07, 2004
Walter
Feb 07, 2004
Phill
Feb 07, 2004
Phill
February 06, 2004
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.




February 06, 2004
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.
>
>
>
>


February 07, 2004
"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.
> >
> >
> >
> >
>
>


February 07, 2004
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.
> > >
> > >
> > >
> > >
> >
> >
>
>


February 07, 2004
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.
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>


February 07, 2004
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.
> > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>


February 07, 2004
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.
> > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>