int Ns_BeginDetachedThread( Ns_ThreadProc *start_routine, void *arg );
Ns_BeginDetachedThread creates a thread which cleans up its data as soon as it ends. Note that detached threads' ids can be reused immediately by the system, and they cannot be waited on.
static void ThreadStart(void *arg) { int n; n = (int) arg; Ns_Log(Notice, "%d: %d", Ns_GetThreadId(), n); } /* * ManyThreads - Create 10 threads which all log a message. */ static void ManyThreads(void) { int i; for (i = 0; i < 10; ++i) { Ns_BeginDetachedThread(ThreadStart, (void *) i); } }