System.currentTimeMillis() is influenced by system time corrections whereas System.nanoTime() is strongly sequential. So it is better to use System.nanoTime() when checking for timeouts and elapsed time.