fix #3479: IllegalStateExceptions due to wrong waiting