public abstract class WatchService extends Object implements Closeable
| Modifier | Constructor and Description |
|---|---|
protected |
WatchService() |
| Modifier and Type | Method and Description |
|---|---|
abstract void |
close()
Closes this watch service.
|
static WatchService |
newWatchService() |
abstract WatchKey |
poll()
Retrieves and removes the next watch key, or
null if none are
present. |
abstract WatchKey |
poll(long timeout,
TimeUnit unit)
Retrieves and removes the next watch key, waiting if necessary up to the
specified wait time if none are yet present.
|
abstract WatchKey |
take()
Retrieves and removes next watch key, waiting if none are yet present.
|
public abstract void close()
throws IOException
Closes this watch service.
<p/>
<p> If a thread is currently blocked in the take or poll methods waiting for a key to be queued then
it immediately receives a ClosedWatchServiceException. Any
valid keys associated with this watch service are invalidated.
<p/>
<p> After a watch service is closed, any further attempt to invoke
operations upon it will throw ClosedWatchServiceException.
If this watch service is already closed then invoking this method
has no effect.
close in interface Closeableclose in interface AutoCloseableIOException - if an I/O error occurspublic abstract WatchKey poll()
Retrieves and removes the next watch key, or null if none are
present.
nullClosedWatchServiceException - if this watch service is closedpublic abstract WatchKey poll(long timeout, TimeUnit unit) throws InterruptedException
Retrieves and removes the next watch key, waiting if necessary up to the specified wait time if none are yet present.
timeout - how to wait before giving up, in units of unitunit - a TimeUnit determining how to interpret the timeout
parameternullClosedWatchServiceException - if this watch service is closed, or it is closed while waiting
for the next keyInterruptedException - if interrupted while waitingpublic abstract WatchKey take() throws InterruptedException
Retrieves and removes next watch key, waiting if none are yet present.
ClosedWatchServiceException - if this watch service is closed, or it is closed while waiting
for the next keyInterruptedException - if interrupted while waitingpublic static WatchService newWatchService()
Copyright © 2015. All rights reserved.