有这么一个线程,执行体是这样的
 procedure TTestThread.Execute;
 begin
   while not Self.Terminated do
   begin
     Windows.Sleep(60000);  // 1 minutes
     
     Self.DoSth;   
   end;
 end;就是每隔一个分钟做点事,怎样在它1分钟Sleep的时候,打断Sleep,提前一次做Self.DoSth;说白了,就是如何唤起slept thread

解决方案 »

  1.   

    线程休眠:SleepEx(xx,true)
    线程唤醒:QueueUserAPC
      

  2.   

    操作系统原理。进程执行Sleep时,由于时间未到,处于“未就绪”队列中。收到一个消息后,满足执行条件,就应该挪到“就绪”队列中。
      

  3.   

    找到几篇帖子:
    http://61.186.252.131/Expert/topic/1002/1002079.xml?temp=.7805292
    http://61.186.252.131/Expert/topic/2287/2287143.xml?temp=.6874658
    http://www.book23.com/data/web5304/20050228/20050228__3584129.html