Top Description Fields Constructors Methods
org.eclipse.jgit.util.io

public Class StreamCopyThread

extends Thread
Class Inheritance
Imports
java.io.IOException, .InputStream, .InterruptedIOException, .OutputStream

Thread to copy from an input stream to an output stream.

Field Summary

Modifier and TypeField and Description
private static final int
private volatile boolean
private final OutputStream
private final InputStream
private final Object
writeLock

Lock held by flush to avoid interrupting a write.

Inherited from java.lang.Thread:
MAX_PRIORITYMIN_PRIORITYNORM_PRIORITY

Constructor Summary

AccessConstructor and Description
public
StreamCopyThread(InputStream
stream to copy from. The thread terminates when this stream reaches EOF. The thread closes this stream before it exits.
i
,
OutputStream
stream to copy into. The destination stream is automatically closed when the thread terminates.
o
)

Create a thread to copy data from an input stream to an output stream.

Method Summary

Modifier and TypeMethod and Description
public void
halt()

Request that the thread terminate, and wait for it.

public void
run()

Overrides java.lang.Thread.run.

Implements java.lang.Runnable.run.

This method is run by the thread when it executes.

Inherited from java.lang.Thread:
activeCountcheckAccessclonecurrentThreaddumpStackenumerategetAllStackTracesgetContextClassLoadergetDefaultUncaughtExceptionHandlergetIdgetNamegetPrioritygetStackTracegetStategetThreadGroupgetUncaughtExceptionHandlerholdsLockinterruptinterruptedisAliveisDaemonisInterruptedisVirtualjoinjoinjoinjoinofPlatformofVirtualonSpinWaitsetContextClassLoadersetDaemonsetDefaultUncaughtExceptionHandlersetNamesetPrioritysetUncaughtExceptionHandlersleepsleepsleepstartstartVirtualThreadstopthreadIdtoStringyield

Field Detail

BUFFER_SIZEback to summary
private static final int BUFFER_SIZE
doneback to summary
private volatile boolean done
dstback to summary
private final OutputStream dst
srcback to summary
private final InputStream src
writeLockback to summary
private final Object writeLock

Lock held by flush to avoid interrupting a write.

Constructor Detail

StreamCopyThreadback to summary
public StreamCopyThread(InputStream i, OutputStream o)

Create a thread to copy data from an input stream to an output stream.

Parameters
i:InputStream

stream to copy from. The thread terminates when this stream reaches EOF. The thread closes this stream before it exits.

o:OutputStream

stream to copy into. The destination stream is automatically closed when the thread terminates.

Method Detail

haltback to summary
public void halt() throws InterruptedException

Request 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.

Exceptions
InterruptedException:
the calling thread was interrupted.
runback to summary
public void run()

Overrides java.lang.Thread.run.

Implements java.lang.Runnable.run.

Doc from java.lang.Thread.run.

This method is run by the thread when it executes. Subclasses of Thread may override this method.

This method is not intended to be invoked directly. If this thread is a platform thread created with a Runnable task then invoking this method will invoke the task's run method. If this thread is a virtual thread then invoking this method directly does nothing.

Annotations
@Override