Duplicated changes described in issue

https://github.com/TooTallNate/Java-WebSocket/issues/171

so that a 100% CPU utilization issue could be resolved