print a line for the firstt time and then every 30 minutes
<p>I have a below method which will be called every one minute from background thread.</p>

<pre><code>public void testMethod() {
    // some other code

    System.out.println("hello")

    // some other code
}
</code></pre>

<p>Now every one minute, <code>hello</code> line will get printed out. Is there any way, by which hello line should get printed for the first time and then after every half an hour (it doesn't have to be exact half an hour) once testMethod is invoked by background thread. I don't want to use any executors or timer class. </p>

<p>I just don't want my hello line gets printed out every one minute. In the starting it should print once and then every 30-35 minutes is fine. Is there any other way to do this without using Timer or Executors? Can we not use current time and do some mod check?</p>

<p>I want all other code in testMethod to get executed every one minute so I cannot sleep or anything. I just need to have some random check by which we can decide whether to print hello or not. I just don't want to print hello every one minute.</p>