Quote Originally Posted by ecce View Post
Like this?
Not quite.

You need to connect before you call start, otherwise the thread could have started and finished before the caller thread had a chance to establish the connection.

The most important principle of multithread programming is to never make assumptions of when something gets executed, unless such an assumption is enforced by means like synchronization or, like in this case, doing things before there is any concurrent execution.

Cheers,
_