1 // Test that threads are reused.
2 // On Android, pthread_* are in libc.so. So the `-lpthread` is not supported.
3 // Use `-pthread` so that its driver will DTRT (ie., ignore it).
4 // RUN: %clangxx_lsan %s -o %t -pthread && %run %t
5 
6 #include <pthread.h>
7 #include <stdlib.h>
8 
9 // Number of threads to create. This value is greater than kMaxThreads in
10 // lsan_thread.cpp so that we can test that thread contexts are not being
11 // reused.
12 static const size_t kTestThreads = 10000;
13 
14 void *null_func(void *args) {
15   return NULL;
16 }
17 
18 int main(void) {
19   for (size_t i = 0; i < kTestThreads; i++) {
20     pthread_t thread;
21     pthread_create(&thread, NULL, null_func, NULL);
22     pthread_detach(thread);
23   }
24   return 0;
25 }
26