blob: 0b106d7a276604e45fe071ca29a254f28b1de726 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
package cbt;
import java.io.*;
public class ThreadLocalOutputStream extends OutputStream{
final public ThreadLocal<OutputStream> threadLocal;
final private OutputStream initialValue;
public ThreadLocalOutputStream( OutputStream initialValue ){
this.initialValue = initialValue;
threadLocal = new ThreadLocal<OutputStream>() {
@Override protected OutputStream initialValue() {
return ThreadLocalOutputStream.this.initialValue;
}
};
}
public OutputStream get(){
return threadLocal.get();
}
public void set( OutputStream outputStream ){
threadLocal.set( outputStream );
}
public void write( int b ) throws IOException{
// after implementing this I realized NailgunLauncher uses the same hack,
// so probably this is not a problem performance
get().write(b);
}
public void flush() throws IOException{
get().flush();
}
}
|