stress.c
来自「UNIX/LINUX平台下面SMS网管原代码」· C语言 代码 · 共 31 行
C
31 行
#include <stdio.h> #include <pthread.h> extern void TestEntry();int main(void) { int i = 0; pthread_t tid1,tid2, tid3; pthread_t tid4,tid5, tid6; pthread_attr_t attr; pthread_attr_init(&attr); //pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); for(i = 0; i < 50; i++) { pthread_create(&tid1, &attr, (void *)TestEntry, NULL); pthread_create(&tid2, &attr, (void *)TestEntry, NULL); pthread_create(&tid3, &attr, (void *)TestEntry, NULL); pthread_create(&tid4, &attr, (void *)TestEntry, NULL); pthread_create(&tid5, &attr, (void *)TestEntry, NULL); } printf("main thread exit\n"); return 0; }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?