#include "stressThreads.h" ClassImp(stressThreads); TFile** stressThreads::files=NULL; TTree** stressThreads::trees=NULL; int* stressThreads::thedata=NULL; int** stressThreads::threadInstructions=NULL; int stressThreads::loopsPerThread=0; TThread** stressThreads::threads=NULL; stressThreads::stressThreads(int nThreads, int loopsPerThread_){ loopsPerThread = loopsPerThread_; files = new TFile*[nThreads]; trees = new TTree*[nThreads]; thedata = new int[nThreads]; threads = new TThread*[nThreads]; threadInstructions = new int*[nThreads]; // create the files, trees, threads etc for (int i=0; iSetDirectory(files[i]); trees[i]->Branch("data", &(thedata[i]), "data/I"); // trees[i]->SetAutoSave(10000); threadInstructions[i] = new int[1]; threadInstructions[i][0] = i;// just the thread index threads[i] = new TThread(Form("thread_%d", i), loop, (void*)threadInstructions[i]); } // Make sure the meta is correctly set before starting the threads. TFile *tempFile = TFile::Open("/var/tmp/mytemp.root","RECREATE"); TTree *tempTree = new TTree("temp","temp"); int val = 0; tempTree->Branch("data",&val); tempTree->Fill(); tempTree->Write(); tempFile->Write(); delete tempFile; gSystem->Unlink("/var/tmp/mytemp.root"); gDirectory = 0; cout<<"running"<Run(); for (int i=0; iJoin(); for (int i=0; icd(); files[i]->Write(); delete files[i]; } cout<<"done"<Fill(); } //write and close //trees[threadIndex]->AutoSave("flushbaskets"); return 0; }