主程序里怎么判断是否还有线程在执行?如何强行终止它?

解决方案 »

  1.   

    创建线程后保留线程句柄,然后用GetExitCodeThread判断线程是否结束,用TerminateThread强制结束线程。
      

  2.   

    使用GetExitCodeThread函数进行判断。If the specified thread has not terminated, the termination status returned is STILL_ACTIVE. The following termination statuses can be returned if the process has terminated: The exit value specified in the ExitThread or TerminateThread function 
    The return value from the thread function 
    The exit value of the thread's process 
      

  3.   

    WaitForSingleObject Thead Handle 有信号 Thead 还在运行,无信号,已经退出