Re: Thread.sleep takes a lot of CPU time!



Hi

The important point of my posting (sorry, I thought, this was obvious) was, that if an exception occurs, sleep() will never be reached and never executed. If the catch-block does really nothing (even not logging the error), then you do not even see that sleep() is never reached.

You must reorder your statements:

>> public void run()
>> {
>> ...
>>
>> while(true)
>> {
>> try {
>> ...
>> //some set of operations
>> ....
>>

// Thread.sleep() removed here...

>> } catch(Exception e) {
>> // do nothing
>> }

// is now here:
>> Thread.sleep(5*1000*60);

>> }

Ciao,
Ingo

.



Relevant Pages

  • Re: Thread.sleep takes a lot of CPU time!
    ... Ingo R. Homann wrote: ... The important point of my posting ... was, that if an exception occurs, sleepwill never be reached and ... then you do not even see that sleep() is never reached. ...
    (comp.lang.java.help)
  • threats from radio-mart
    ... what's the matter, you are not responding,,,, you gone to sleep? ... my words and posting everywhere you can?? ...
    (rec.radio.shortwave)
  • Re: new ultivillage footage posts?
    ... days at the field and my need for sleep. ... I'm posting the Kansas vs ... Pittsburgh game right now and plan to have all the content up by ...
    (rec.sport.disc)
  • Re: new ultivillage footage posts?
    ... days at the field and my need for sleep. ... I'm posting the Kansas vs ... Pittsburgh game right now and plan to have all the content up by ...
    (rec.sport.disc)
  • Re: Anyone ever get the feeling some members are posting drunk?
    ... I sometimes have a couple of beer but then I go straight to ... sleep. ... No posting. ... The last time I posted drunk, ...
    (rec.sport.tennis)