Produce an IAEA phase space file for the LINAC head using a multi-threaded computation mode

I simulated a LINAC head and generated an IAEA Phase Space file.
If I used a single calculation mode, the resulting files would be expected. If I used multi-computation mode (multi threads), the resulting IAEAheader file was empty.
Can someone kindly assist me?

Where is the file opened? If it is opened via a function call, does that function have a mutex lock included to prevent multiple threads from stomping on each other?

Is it possible to generate the IAEA file after the fact, using data written out via G4Analysis (such as N-tuples)? G4Analysis is written to be thread safe, and to properly merge the data from multiple threads.

Dear @mkelsey,
I used the example here. Files are written with the G4IAEAphspWriter class. In SteppingAction, EventAction, and RunAction Class we must call the methods that are defined in G4IAEAphspWriter to storage particles in an IAEAphsp file.

This sounds like an issue for contacting the author of that example. There is general Geant4 documentation on multithreading: Parallelism in Geant4: multi-threading capabilities — Geant4 Documentation 11.0 documentation

You may need to make some modifications to the code to be properly thread safe.