Skip to content

Instantly share code, notes, and snippets.

@styxyang
styxyang / test_pool.c
Last active December 18, 2015 22:29
It's not a good idea to pass a stack temporary variable(structure) to thread routine: 1. we don't know the execution sequence of created threads 2. the temporary variable(structure) may get cleared before the sub threads access it
/* definition of thread argument passed to pool wrapper*/
typedef struct {
thread_pool *pool;
uint64_t id;
} thread_argument;
//////////////////////////////////////////////////////////////
// thread_pool_wrapper: thread start routine waiting for tasks
// to execute
/////////////////////////////////////////////////////////////