1. 首先咱們想到的就是共享內存,好比說用全局變量,各類event,可是用這種方式要記得加鎖;編程
2. 用消息,可是要先建立消息隊列;用SendMessage,PostThreadMessage之類的函數; 在接收消息的線程寫:函數
MSG msg; memset ( &msg, 0, sizeof ( MSG ) ); PeekMessage ( &msg, NULL, NULL, NULL, PM_NOREMOVE ); int ret = GetMessage ( &msg, NULL, NULL, NULL ); if ( msg.message == WM_QUIT ) return 0;
3. 用APC隊列, 《Windows核心編程》10.5.3節提起線程