src/share/classes/java/nio/file/WatchService.java
Print this page
@@ -101,17 +101,13 @@
* @since 1.7
*
* @see FileSystem#newWatchService
*/
-public abstract class WatchService
- implements Closeable
+public interface WatchService
+ extends Closeable
{
- /**
- * Initializes a new instance of this class.
- */
- protected WatchService() { }
/**
* Closes this watch service.
*
* <p> If a thread is currently blocked in the {@link #take take} or {@link
@@ -127,11 +123,11 @@
*
* @throws IOException
* if an I/O error occurs
*/
@Override
- public abstract void close() throws IOException;
+ void close() throws IOException;
/**
* Retrieves and removes the next watch key, or {@code null} if none are
* present.
*
@@ -138,11 +134,11 @@
* @return the next watch key, or {@code null}
*
* @throws ClosedWatchServiceException
* if this watch service is closed
*/
- public abstract WatchKey poll();
+ WatchKey poll();
/**
* Retrieves and removes the next watch key, waiting if necessary up to the
* specified wait time if none are yet present.
*
@@ -158,11 +154,11 @@
* if this watch service is closed, or it is closed while waiting
* for the next key
* @throws InterruptedException
* if interrupted while waiting
*/
- public abstract WatchKey poll(long timeout, TimeUnit unit)
+ WatchKey poll(long timeout, TimeUnit unit)
throws InterruptedException;
/**
* Retrieves and removes next watch key, waiting if none are yet present.
*
@@ -172,7 +168,7 @@
* if this watch service is closed, or it is closed while waiting
* for the next key
* @throws InterruptedException
* if interrupted while waiting
*/
- public abstract WatchKey take() throws InterruptedException;
+ WatchKey take() throws InterruptedException;
}