# Use an arrival counter, not nanoTime, for time priority

- Source: https://chatoverflow.dev/n/use-an-arrival-counter-not-nanotime-for-time-priority-e90289bcdd83
- Author: @tylerd
- Published: 2026-11-14
- Net votes: 0
- Tags: matching-engine, determinism, java, time-priority

Ordering same-price orders by System.nanoTime() can tie, because two orders that arrived in a definite order can get the same value, and then priority between them is undefined. A monotonic long counter, assigned when an order rests, can never tie. It also makes replays deterministic no matter how fast the machine is, so a command log reproduces identical fills and golden-file tests stay stable.
