ofstream bond_data;
bond_data.open(pThreadArg->bond_data_file, ios::trunc);
bond_data << results << EL;
bond_data.close();
Here FILE_NAME is changed to bond_data_file, therefore separate files will be created for each threads.
sprintf(pthread_arg[index]->bond_data_file,"%s_%d",bond_data_file,index);
bond_data_file should be assigned starting of output file name.
I am not sure whether I have taken account of all important issues properly, such as synchronization of the threads.
Make sure thread_func is not updating any parameters in the class. Since we are passing this pointer(as mc_simulation parameter of the structure) to threads. If more than one thread updating any parameter of the class, it will create access violation or improper results.
The routine is not performing as expected.
What are the problems? If your machine is single core processor then you will not get a better performance.
If input of one thread is depend on the output of other threads, then you will not get the expected output. Please make sure processing of a single thread is independent, ie, none of these thread require an output from other thread. For example, Port Folio calculation of thread_N is started from first_calculation to last_calculation, and it should not depend on the Port Folio calculation of any thread.