Roger Luo

超越梦想一起飞
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Question Need to Find out

Posted on 2013-04-27 21:30  Roger Luo  阅读(140)  评论(0编辑  收藏  举报

? Differences between CreateThread and _beginthread

! There are four methods to terminate sub thread

  • return from the end of the function
  • ExitThread itself
  • TerminateThread by other thread
  • Terminate the owed process

? windows code should be using ExitThread; c/c++ code should be used _endthread to terminate the thread. So definition of windows code and c++/c code?

! ExitThread以及函数返回能够释放分配给线程的堆栈空间,然后使用TerminateThread将不会通知被关闭线程(同时他也是异步的),如果使用了这个方法,就只能等待拥有这个线程的进程关闭来释放。这个原理是windows估值设计,同时也适用于DLL创建的线程。