Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      thrd_create

      From cppreference.com
      <c‎ |thread
       
       
      Concurrency support library
       
      Defined in header<threads.h>
      int thrd_create(thrd_t*thr,thrd_start_t func,void*arg);
      (since C11)

      Creates a new thread executing the functionfunc. The function is invoked asfunc(arg).

      If successful, the object pointed to bythr is set to the identifier of the new thread.

      The completion of this functionsynchronizes-with the beginning of the thread.

      Contents

      [edit]Parameters

      thr - pointer to memory location to put the identifier of the new thread
      func - function to execute
      arg - argument to pass to the function

      [edit]Return value

      thrd_success if the creation of the new thread was successful. Otherwise returnsthrd_nomem if there was insufficient amount of memory orthrd_error if another error occurred.

      [edit]Notes

      The thread identifiers may be reused for new threads once the thread has finished and joined or detached.

      The typethrd_start_t is a typedef ofint(*)(void*), which differs from the POSIX equivalentvoid*(*)(void*)

      All thread-specific storage values (seetss_create) are initialized toNULL.

      Return from the functionfunc is equivalent to callingthrd_exit with the argument equal to the return value offunc.

      [edit]References

      • C17 standard (ISO/IEC 9899:2018):
      • 7.26.5.1 The thrd_create function (p: 279)
      • C11 standard (ISO/IEC 9899:2011):
      • 7.26.5.1 The thrd_create function (p: 383)

      [edit]See also

      detaches a thread
      (function)[edit]
      blocks until a thread terminates
      (function)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=c/thread/thrd_create&oldid=146644"

      [8]ページ先頭

      ©2009-2025 Movatter.jp