diff --git a/classpath/java/nio/channels/SocketSelector.java b/classpath/java/nio/channels/SocketSelector.java index 2482d0f180..2d5cdbd699 100644 --- a/classpath/java/nio/channels/SocketSelector.java +++ b/classpath/java/nio/channels/SocketSelector.java @@ -106,8 +106,11 @@ class SocketSelector extends Selector { return selectedKeys.size(); } - public void close() { - natClose(state); + public synchronized void close() { + if (isOpen()) { + natClose(state); + state = 0; + } } private static native long natInit();