I want my main thread to be running, as I have some listener that will be listening to request/messages in another thread and I don't want my main thread to die.
Which one is better
public static void main(String[] args) throws InterruptedException {startListener(); CountDownLatch latch = new CountDownLatch(1); latch.await();
}
public static void main(String[] args) throws InterruptedException {startListener(); while (true){ Thread.sleep(1000); }
}
#java #multithreading