I'm trying to run a `java.util.Timer` every three seconds, and I need to delay it by another 2 at a certain condition. To check whether this could be achived using `Thread.sleep()`, I wrote the code below.

```
Timer t = new Timer();

t.schedule(new TimerTask() {
    @Override
    public void run() {
        if (true) { //When this is false timer should continue at 3 second interval.
            try {
                Thread.currentThread().sleep(2000); //Delay by another 2 seconds.
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
        System.out.println(new Date());
    }
}, 0, 3000); //Trigger every 3 seconds.

```

I'm expecting to print timestamps with a difference of 5 seconds. But I'm getting it with a 3 second difference.

```
Tue Sep 18 15:08:17 IST 2018
Tue Sep 18 15:08:20 IST 2018
Tue Sep 18 15:08:23 IST 2018
Tue Sep 18 15:08:26 IST 2018
Tue Sep 18 15:08:29 IST 2018

```

What am I missing?