public class SnzMTInputStream extends SnzInputStream
Alternative to SnzInputStream with support for multi-threaded decomression.
By default, SnzMTInputStream will use a default ThreadPoolExecutor with a core size
set to the number of available CPUs and a maximum size of twice the number of available
CPUs. The threads used yby the default executor will be started as daemon threads.
The default executor is not created until actually requried and can be queried and
replaced with the static getDefaultExecutor and setDefaultExecutor
methods.
in| Constructor and Description |
|---|
SnzMTInputStream(InputStream in)
Creates an input stream, which reads from the specified input
and uses the default executor.
|
SnzMTInputStream(InputStream in,
Executor executor)
Creates an input stream, which reads from the specified input
and uses the provided executor instead of the default executor.
|
| Modifier and Type | Method and Description |
|---|---|
static Executor |
getDefaultExecutor()
Returns the default executor or null if no default executor has
been created yet.
|
int |
read(byte[] b,
int off,
int len)
Fills the byte array with data from the uncompressed stream starting
at the specified
offset and no more than length bytes. |
static void |
setDefaultExecutor(Executor executor)
Sets a new default executor.
|
getBlockSize, read, readavailable, close, mark, markSupported, reset, skippublic SnzMTInputStream(InputStream in)
in - public SnzMTInputStream(InputStream in, Executor executor)
in - executor - public int read(byte[] b,
int off,
int len)
throws IOException
SnzInputStreamoffset and no more than length bytes.read in class SnzInputStreamb - destination arrayoff - offset into the byte array, on which the data is writtenIOExceptionpublic static Executor getDefaultExecutor()
public static void setDefaultExecutor(Executor executor)
Sets a new default executor.
Setting a new default executor will have no effect on already created instances of this class. Setting the default executor to null will cause a new default executor to be created when needed.
Note that replacing a running executor will not cause the previous default executor to be automatically shut down.
executor - a new default executorCopyright © 2014 AVAST Software. All Rights Reserved.