I need to record the exact order in which a method is called by various threads in Java. I’m supposed to use an object timeProvider which returns non-decreasing long integers. The solution I have come up with is: Of course it is a bottleneck because the only place I need to use synchronization is the first line. So I’m wondering