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 #include <unistd.h> 9 10 // Number of threads to create. This value is greater than kMaxThreads in 11 // lsan_thread.cpp so that we can test that thread contexts are not being 12 // reused. 13 static const size_t kTestThreads = 10000; 14 15 void *null_func(void *args) { 16 return NULL; 17 } 18 19 int main(void) { 20 for (size_t i = 0; i < kTestThreads; i++) { 21 pthread_t thread; 22 if (pthread_create(&thread, NULL, null_func, NULL) == 0) 23 pthread_detach(thread); 24 } 25 return 0; 26 } 27