public class StreamCopyThread
extends java.lang.Thread
Modifier and Type | Field and Description |
---|---|
private static int |
BUFFER_SIZE |
private boolean |
done |
private java.io.OutputStream |
dst |
private java.io.InputStream |
src |
private java.lang.Object |
writeLock
Lock held by flush to avoid interrupting a write.
|
Constructor and Description |
---|
StreamCopyThread(java.io.InputStream i,
java.io.OutputStream o)
Create a thread to copy data from an input stream to an output stream.
|
Modifier and Type | Method and Description |
---|---|
void |
halt()
Request that the thread terminate, and wait for it.
|
void |
run() |
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
private static final int BUFFER_SIZE
private final java.io.InputStream src
private final java.io.OutputStream dst
private volatile boolean done
private final java.lang.Object writeLock
public StreamCopyThread(java.io.InputStream i, java.io.OutputStream o)
i
- stream to copy from. The thread terminates when this stream
reaches EOF. The thread closes this stream before it exits.o
- stream to copy into. The destination stream is automatically
closed when the thread terminates.public void halt() throws java.lang.InterruptedException
This method signals to the copy thread that it should stop as soon as there is no more IO occurring.
java.lang.InterruptedException
- the calling thread was interrupted.public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread