in reply to Is it OK for Time::HiRes::time() to report the time differently per thread?

I think the output is consistent. For each thread id, the first output is before the next output.

I don't know how your OS schedules the different threads, but you cannot really rely on all threads getting scheduled in parallel.

Update: For the different ordering, you are likely falling afoul of output buffering. But as there are more/other locks in play, it's hard to say.

Replies are listed 'Best First'.
Re^2: Is it OK for Time::HiRes::time() to report the time differently per thread?
by ikegami (Patriarch) on Apr 23, 2026 at 16:28 UTC

    I think the output is consistent. For each thread id, the first output is before the next output.

    That's not what the OP wants. The OP want to bar the threads from proceeding to obtaining the "next" time only after every thread has reached that point.

    However, the implementation of the barrier is flawed. A race condition exists.