Reimplement timer with Java