#include <iostream>
using namespace std;
#include <pthread.h>

// data structure used to pass argument to thread
typedef struct {
	int value;
} thread_data;

// thread to execute
void *code(void *arg) {
	// get data
	thread_data *data = (thread_data *) arg;
	cerr << "i = " << data->value << endl;
}

int main() {
	// array of threads
	pthread_t t[10];
	// array of data for threads
	thread_data td[10];
	
	// create threads
	for (int i=0; i<10; ++i) {
		td[i].value = i;
		pthread_create(&t[i], NULL, code, (void *)&td[i]);
	}
	return 0;
}

