c++ - 如何验证 pthread 函数是否开始执行

标签 c++ multithreading testing pthreads execution

例子:

void start(void)
{
   pthread_create(&threadID, Null, run_thread_function,arguments);

   //is there a way to ensure if the run_thread_function(basically new thread) started   
   //execution before returning from this(start) function    

}

最佳答案

检查返回码。

if ((retcode = pthread_create(&threadID, Null, run_thread_function,arguments)) != 0)
{
   //something went wrong
}

关于c++ - 如何验证 pthread 函数是否开始执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13167318/

相关文章:

c++ - 初始化器究竟是什么时候被临时销毁的?

c# - 运行多个 C# 任务异步

testing - 等待一个链接出现,该链接已经在 selenium 的页面中

unit-testing - tdd - 为第 3 方代码创建测试

c++ - 使用 std::multimap,是否保证 begin() 方法返回最新元素?

C++:如何写这个抽象类?

java - 允许更改 Runnable 对象

multithreading - 为什么 TApplication.MessageBox 自动关闭?

java - 模拟具有通用(?扩展集合)返回类型的方法时遇到问题

c++ - C/C++ 可以通过查询类来获取实例成员的 "list"?