< prev index next > src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java
Print this page
private static final int ST_CONNECTED = 1;
private static final int ST_CLOSING = 2;
private static final int ST_CLOSED = 3;
private int state;
- // IDs of native threads doing reads and writes, for signalling
- private long readerThread;
- private long writerThread;
+ // Threads doing reads and writes, for signalling
+ private Thread readerThread;
+ private Thread writerThread;
// Local and remote (connected) address
private InetSocketAddress localAddress;
private InetSocketAddress remoteAddress;
if ((remote == null) && mustBeConnected)
throw new NotYetConnectedException();
if (localAddress == null)
bindInternal(null);
if (blocking)
- readerThread = NativeThread.current();
+ readerThread = NativeThread.threadToSignal();
}
return remote;
}
/**
private void endRead(boolean blocking, boolean completed)
throws AsynchronousCloseException
{
if (blocking) {
synchronized (stateLock) {
- readerThread = 0;
+ readerThread = null;
if (state == ST_CLOSING) {
tryFinishClose();
}
}
if (interruptible) {
if ((remote == null) && mustBeConnected)
throw new NotYetConnectedException();
if (localAddress == null)
bindInternal(null);
if (blocking)
- writerThread = NativeThread.current();
+ writerThread = NativeThread.threadToSignal();
}
return remote;
}
/**
private void endWrite(boolean blocking, boolean completed)
throws AsynchronousCloseException
{
if (blocking) {
synchronized (stateLock) {
- writerThread = 0;
+ writerThread = null;
if (state == ST_CLOSING) {
tryFinishClose();
}
}
* Closes the socket if there are no I/O operations in progress and the
* channel is not registered with a Selector.
*/
private boolean tryClose() throws IOException {
assert Thread.holdsLock(stateLock) && state == ST_CLOSING;
- if ((readerThread == 0) && (writerThread == 0) && !isRegistered()) {
+ if ((readerThread == null) && (writerThread == null) && !isRegistered()) {
state = ST_CLOSED;
try {
// close socket
cleaner.clean();
} catch (UncheckedIOException ioe) {
< prev index next >