One not recommended solution is to make replace int _listenPort;
with volatile int _listenPort;
. Read this to understand why this solution is not recommended.
A good solution would use synchronized writing and reading of _listenPort.
Or As I suggested before move definitions of class to a different file. This way, compiler won't inline
your code and function will return expected value.