I have this code :
#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);
}
How can I run from shell the ps -Lf, ps -T, ps -Lm simultaneously to the code above?
I mean how can I run both in the shell command prompt? using another Tab doesn’t seem to work properly.
To strictly answer your question, one way to do it is with tmux, in separate terminals in the same window. Open as many as necessary, prep your commands, set tmux to duplicate the input with :setw synchronize-panes on at the tmux prompt, and then hit enter to run all the commands simultaneously. Here’s how it would look like: