I am printing information to test Threads using Reentrant locks. I am creating fair locks using statement new ReentrantLock(true).
In one of the object method where I a
System.out is a buffered stream. This mean that it doesn't fill the console synchroneously.
While the printf() call is synchrone, the console output is not.
You can either:
System.out.flush();,println() which auto-flushes the stream,System.err which is not AFAIK buffered. Not sure about the last one...
Note that your threads are executed concurrently (if you use .start()) Which means you cannot expect precisely any execution order without synchronization elements.