Simply start a new thread for at least one of them (the other thread is already
running, but you might want to create a new thread for it as well).
kind regards,
Jos
Jos, thanks again, but we need your advice again... we've created a sample program to run 10 threads w/c prints values from 1 to 10. We wanted them to run concurrently that's why we used threads but based on the output it seems that they still run in a sequential manner.
Thanks for the help...
CODE:
#include <stdio.h>
#include <iostream>
#include <string>
#include <pthread.h>
using namespace std;
void * printMsg(void * args){
int * msg;
msg = (int *)args;
for(int z=0; z<10 ; z++){
cout << msg << " - " << z << endl;
}
}
int main(){
pthread_t thread_[6];
for(int i=0; i<6; i++){
pthread_create(&thread_[i], NULL ,printMsg, (void *) i);
}
for(int i=0; i<6; i++){
pthread_join(thread_[i], NULL);
}
cout << " --- DONE! --- "<< endl;
}
OUTPUT:
0 - 0
0 - 1
0 - 2
0 - 3
0 - 4
0 - 5
0 - 6
0 - 7
0 - 8
0 - 9
0x1 - 0
0x1 - 1
0x1 - 2
0x1 - 3
0x1 - 4
0x1 - 5
0x1 - 6
0x1 - 7
0x1 - 8
0x1 - 9
0x2 - 0
0x2 - 1
0x2 - 2
0x2 - 3
0x2 - 4
0x2 - 5
0x2 - 6
0x2 - 7
0x2 - 8
0x2 - 9
0x3 - 0
0x3 - 1
0x3 - 2
0x3 - 3
0x3 - 4
0x3 - 5
0x3 - 6
0x3 - 7
0x3 - 8
0x3 - 9
0x4 - 0
0x4 - 1
0x4 - 2
0x4 - 3
0x4 - 4
0x4 - 5
0x4 - 6
0x4 - 7
0x4 - 8
0x4 - 9
0x5 - 0
0x5 - 1
0x5 - 2
0x5 - 3
0x5 - 4
0x5 - 5
0x5 - 6
0x5 - 7
0x5 - 8
0x5 - 9
--- DONE! ---