pthread_once.3t (2010 09)
p
pthread_once(3T) pthread_once(3T)
(Pthread Library)
For a multithreaded process, a simple initialization flag is not sufficient; the flag must be protected
against modification by multiple threads. Consequently, this flag has to be protected by a mutex that has
to be initialized only once, and so on. A multithreaded program should use initialization similar to:
static pthread_once_t once_control = PTHREAD_ONCE_INIT;
extern void initialize();
(void)pthread_once(&once_control, initialize);
(Rest of the code after initialization.)
AUTHOR
pthread_once()
was derived from the IEEE POSIX P1003.1c standard.
SEE ALSO
pthread_create(3T).
STANDARDS CONFORMANCE
pthread_once()
: POSIX 1003.1c.
2 Hewlett-Packard Company − 2 − HP-UX 11i Version 3: September 2010