我有这个代码:
#include <iostream>
#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
using namespace std;
void* printHello (void* threadId){
cout << "in print Hello"<< (long) threadId << endl;
pthread_exit(NULL);
}
#define num 1000000
int main () {
pthread_t threads [num];
int rc;
long t;
for (t=0 ; t<num; ++t){
cout <<"in main" << "thread Id = " << t << endl;
rc = pthread_create(&threads[t] , NULL , printHello , (void*)t);
if (rc) {
cout << "ERROR"<< "rc= "<< rc << endl;
exit(-1);
}
}
pthread_exit(NULL);
}
如何从 shellps -Lf, ps -T, ps -Lm
同时运行到上面的代码?我的意思是如何在 shell 命令提示符下运行两者?使用另一个选项卡似乎无法正常工作。