各位大侠小弟想知道有关线程同步的问题。
就是刚学到线程,对线程的同步不是很清楚(信号量,互斥,临世区,和事件),那位大侠有这方面
的资料,特别是事件。如果能给一点代码就更好。谢谢

解决方案 »

  1.   

    《Delphi(5、6) 开发人员指南》
      

  2.   

    Events
    An event object is a synchronization object that is under the direct control of the application.
    Instead of changing state as a result of calling one of the wait functions (such as
    WaitForSingleObject), the application can use three different functions to control the state
    of the object. The SetEvent function sets the state of the event object to signaled, the
    ResetEvent function sets the state of the event object to non-signaled, and the PulseEvent
    function quickly sets the state of the event object to signaled and then non-signaled. When
    the event object is created, the application can determine if it will be a manual or automatic
    reset event. Manual reset events remain signaled until explicitly reset to nonsignaled
    by a call to the ResetEvent function. Auto reset events remain signaled until a
    single waiting thread is resumed, at which point the system automatically sets the state
    back to non-signaled. A deadlock can occur when a thread is suspended in a permanent
    wait state as a result of a lost event object. If PulseEvent or SetEvent is used with an auto
    reset event and no threads are waiting, the event object is lost and a deadlock will occur.
    Events are especially useful in the situation where a thread must wait for another thread to
    complete its execution. The executing thread can simply set the event’s state to signaled at
    the end of its execution, at which point the waiting thread will resume, guaranteed that the
    thread upon which it was waiting has successfully completed.
    CreateEvent                       Creates an event object.
    OpenEvent                         Opens a handle to an existing event object.
    PulseEvent                        Rapidly sets the state of an event object to signaled 
                                       and unsignaled.
    ResetEvent                        Resets an event object to an unsignaled state.
    SetEvent                          Sets the state of an event object to signaled.
      

  3.   

    下载地址:
    http://www.hktk.com/soft/program/book/delphi/delphi_83.html另外,其实到Google或 baidu搜索一下就有的
      

  4.   

    delphi开发人员指南讲的很详细,相信在网上也能找到,