'Wait for a thread to successfully start

I'm wondering how to log information when a server has successfully started. I cannot do this as simple as that:

createServer().start(Exit.NEVER);
System.out.println("Server is running...");

because the instruction createServer().start(Exit.NEVER) doesn't return back. This is a call to external library that uses a method with a loop similar to while(true). I cannot also run the server in a new thread and then log information about successful start because the server may throw exception and hence there was a failure.

public void start () {
        new Thread("Server") {
            @Override
            public void run() {
                try {
                    createServer().start(Exit.NEVER);
                } catch (final IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
        }.start();

        System.out.println("Server is running...");
}

Last solution I can think of is to wait a couple of second after createServer().start(Exit.NEVER) and then log the successful start as there was no exception thrown. This is not a perfect solution as we can wait for example 5 seconds and the log the successful start but one second later the server may throw exception.

How do I then can tell whether the server has started successfully and hence log this information?

EDIT

The server I'm using is Takes https://github.com/yegor256/takes.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source