【问题标题】:Can threads have more than one argument?线程可以有多个参数吗?
【发布时间】:2010-02-14 06:17:45
【问题描述】:

线程可以有多个参数而不使用结构吗?

所以...有点像:

pthread_create(&file_thread, NULL, merge_thread, sortedFiles, number); 

... 'number' 是额外的参数在哪里?

谢谢, 赫里斯托

【问题讨论】:

标签: c arguments pthreads


【解决方案1】:

没有。您必须定义一个结构来包含各种参数,并将指向该结构实例的指针作为单个void* 参数传递给pthread_create

【讨论】:

  • 我希望有另一种方式。谢谢。
  • Hristo:明智地使用包装函数可以为您隐藏结构的使用。
猜你喜欢
  • 1970-01-01
  • 2011-03-09
  • 2016-03-25
  • 1970-01-01
  • 2014-05-11
  • 2011-08-06
  • 2020-01-29
相关资源
最近更新 更多