Four approaches
-
Copy all argumnets to the thread's stack: not supported!
pthread initial functions only take 1 argument.
-
Pass a pointer to local storage containing the arguments:
Ok if we are certain this storage doesn't go out of scope until the thread is finished with it!
-
Pass a pointer to static or global storage containing the arguments:
Works only if only one thread at a time is using the storage.
-
Pass a pointer to dynamically allocated storage containing the arguments.
This works provided the storage can be released (free()) when (and only when) the thread is finished with it.