Write several TMemFile in parallel


I would like to write data from several threads into TMemFile (one TMemFile per thread) and then send them to a server through sockets in order to merge into one file and write it to disk. I saw the example of the parallelMerge client and server which can merge TParallelMergingFile from several clients.

Is there a way to write data (TTree for example) into several TMemFile in parallel ?
I have some segfault if I try to run the parallelMergeClient with TThread (my version of ROOT is 5.34/21).

Thank you!