Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #32937

thread sleeping until event

Newsgroups comp.lang.java.programmer
Date 2015-10-27 02:41 -0700
Message-ID <65ba7e2b-caee-4656-b740-b34110b2982c@googlegroups.com> (permalink)
Subject thread sleeping until event
From Philipp Kraus <philipp.kraus.flashpixx@gmail.com>

Show all headers | View raw


Hello,

I have got a main thread running which can be stay in a pause definition. At the moment the main structure is:

volatile boolean mypause = true;

public voud run()
{
while (true)
{
    if (mypause)
         Thread.sleep(1000);

    // thread is working

}
}

public void pause()
{
   mypause = !mypause;
}




If mypause is switch to false the thread should running. So my question is, how can I do a good pause state, so the thread create minimal system  load.

Thanks a lot

Phil

Back to comp.lang.java.programmer | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

thread sleeping until event Philipp Kraus <philipp.kraus.flashpixx@gmail.com> - 2015-10-27 02:41 -0700
  Re: thread sleeping until event Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-10-27 08:36 -0400
    Re: thread sleeping until event Philipp Kraus <philipp.kraus.flashpixx@gmail.com> - 2015-10-27 14:22 -0700

csiph-web