TFile and multithread application

Hi!
I have some problems with my application that use the boost libraries for multithreading.
In particular it should start N threads and each one should work with a different TFile (read a TTree and copy it in a new TFile but it’s not important because I can’t neither reach that part).
I have read that TFiles are not really compatible with multithreading but a suggestion, I found, was open all the TFiles in a function and then pass each of their pointers to the rispective thread.
Unfortunatly it doesn’t work because as soon as I try to open a TTree from the TFile it stops with very bad errors.

I’m quite sure it is a multithread issue because using a “starndard” code works properly and also using threads, but setting the number of threads running concurrently to one, works.

I don’t know what to insert here of my code. I’ll put the most relevant part but if you need more to find the problem I’m ready to post something else…

Here it is the function that creates the pool and launches the runs. It calls the “from6to5” method passing a number it needs to recognize the TFile to open.

[code]void Sorter::parallel_run(string number){
numberOfParallelJobs=4;

//LOAD THE TFILE POINTERS VECTOR - IT USE J TO CREATE FILE NAMES AS:
    //ROOTresult0.root
    //ROOTresult1.root
    //ROOTresult2.root
    //.........

    for (int j=0; j<rootFilesTotalNumber; j++) {
          string tempName = createRootFileName(j);
          rootFileNameVector.push_back(new TFile(tempName.c_str(),"READONLY"));
    }

   //START THE POOL
boost::threadpool::thread_pool<> tpool(numberOfParallelJobs);
for (int j=0; j<rootFilesTotalNumber; j++){
	tpool.schedule(boost::bind(&Sorter::from6to5,this,j));
}

}[/code]


Here the method. The first line works… But it is enough to add the second line to crash the program.

[code]void Sorter::from6to5(int rootFileNumberNew) {

TFile* f = rootFileNameVector.at(rootFileNumberNew);
TTree *Singles = (TTree*)f->Get("Singles");

}[/code]

For the moment I don’t post the error because they are quite a lot of lines and each time it is different.
Thank you in advance!

Giacomo