Package org.eclipse.jgit.util.io
Class StreamCopyThread
- java.lang.Object
-
- java.lang.Thread
-
- org.eclipse.jgit.util.io.StreamCopyThread
-
- All Implemented Interfaces:
java.lang.Runnable
public class StreamCopyThread extends java.lang.ThreadThread to copy from an input stream to an output stream.
-
-
Field Summary
Fields Modifier and Type Field Description private static intBUFFER_SIZEprivate booleandoneprivate java.io.OutputStreamdstprivate java.io.InputStreamsrcprivate java.lang.ObjectwriteLockLock held by flush to avoid interrupting a write.
-
Constructor Summary
Constructors Constructor Description StreamCopyThread(java.io.InputStream i, java.io.OutputStream o)Create a thread to copy data from an input stream to an output stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidhalt()Request that the thread terminate, and wait for it.voidrun()-
Methods inherited from class java.lang.Thread
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
-
-
-
-
Field Detail
-
BUFFER_SIZE
private static final int BUFFER_SIZE
- See Also:
- Constant Field Values
-
src
private final java.io.InputStream src
-
dst
private final java.io.OutputStream dst
-
done
private volatile boolean done
-
writeLock
private final java.lang.Object writeLock
Lock held by flush to avoid interrupting a write.
-
-
Constructor Detail
-
StreamCopyThread
public StreamCopyThread(java.io.InputStream i, java.io.OutputStream o)Create a thread to copy data from an input stream to an output stream.- Parameters:
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.
-
-
Method Detail
-
halt
public void halt() throws java.lang.InterruptedExceptionRequest that the thread terminate, and wait for it.This method signals to the copy thread that it should stop as soon as there is no more IO occurring.
- Throws:
java.lang.InterruptedException- the calling thread was interrupted.
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable- Overrides:
runin classjava.lang.Thread
-
-