[ Previous ] [ Contents ] [ Index ] [ Next ]

Ns_BeginDetachedThread

Overview

Create a detached thread

Syntax

    int Ns_BeginDetachedThread(
    	Ns_ThreadProc *start_routine, 
    	void          *arg
    );

Description

Ns_BeginDetachedThread creates a thread which cleans up its data as soon as it ends. Note that detached thread's ids can be reused immediately by the system, and they cannot be waited on.

Example

    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);
    	}
    }

Top of Page

[ Previous ] [ Contents ] [ Index ] [ Next ]
Copyright © 1996 America Online, Inc.