int main()
{
pthread_t tid[2];
for (int i = 0; i < 2; i++) {
pthread_create(&tid[i], NULL, routine, NULL);
}
for (int i = 0; i < 2; i++)
pthread_join(tid[i], NULL);
return 0;
}
More Related Contents:
- Is atoi multithread safe? [closed]
- Please explain the following parallel code template
- Undefined reference to pthread_create in Linux
- Is errno thread-safe?
- Is malloc thread-safe?
- How do I start threads in plain C?
- When the main thread exits, do other threads also exit?
- Signal handling with multiple threads in Linux
- Kill Thread in Pthread Library
- Is it possible to determine the thread holding a mutex?
- Can I get Unix’s pthread.h to compile in Windows?
- How to signal select() to return immediately?
- C11 GCC threads.h not found?
- fork and existing threads?
- Is changing a pointer considered an atomic action in C?
- How do you query a pthread to see if it is still running?
- Using C/Pthreads: do shared variables need to be volatile?
- Memory order consume usage in C11
- Does any C library implement C11 threads for GNU/Linux?
- Is it possible to access/update the child thread’s resource from parent thread?
- Linux/POSIX equivalent for Win32’s CreateEvent, SetEvent, WaitForSingleObject
- CPU cache inhibition
- Multiple threads and CPU cache
- Which thread handles the signal?
- Unexpected output in a multithreaded program
- What is the difference between fork and thread?
- Can multithreading be implemented on a single processor system?
- Atomically increment two integers with CAS
- How to get the number of CPUs in Linux using C?
- Does “volatile” guarantee anything at all in portable C code for multi-core systems?