I am using [this guide](http://docs.spring.io/spring/docs/current/spring-framework-reference/html/websocket.html#websocket-stomp-client) to implement a simple Stomp client:

```
WebSocketClient webSocketClient = new StandardWebSocketClient();
WebSocketStompClient stompClient = new WebSocketStompClient(webSocketClient);

ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
taskScheduler.afterPropertiesSet();
stompClient.setTaskScheduler(taskScheduler); // for heartbeats

stompClient.setMessageConverter(new StringMessageConverter());

StompSessionHandler sessionHandler = new MySessionHandler();
stompClient.connect("ws://server/endpoint", sessionHandler);

// WAITING HERE

```

When connection completes it's supposed to report to `MySessionHandler` asynchronously:

```
public class MySessionHandler extends StompSessionHandlerAdapter
{
     @Override
     public void afterConnected(StompSession session, StompHeaders connectedHeaders) 
     {
         // WAITING FOR THIS
     }
}

```

So question is: how the line `WAITING HERE` should wait for the line `WAITING FOR THIS`? Is there a specific Spring way of doing this? If not, which generic Java way fits here the best?