title: How to stop the program until a certain condition is met?
body: <p>a question:</p>
  
  <p>the main program is executed in the main thread. An object of class Timer (swing) generates an event every 30 seconds.</p>
  
  <p>As a result of this, the handler of this event is launched (in a parallel thread).</p>
  
  <p>I need to stop the main thread from executing while the event handler will execute.</p>
  
  <p>Those. as soon as the timer handler starts executing, the main program should stop (it has a pause).</p>
  
  <p>And as soon as the timer handler completes its work, the main program should continue its work.</p>
  
  <p>Tell me, with what help is it more convenient and more correct to solve this problem?</p>