On 9/20/2013 5:25 PM, Remi Forax wrote:
What you can do is to call a function that will take the stream as argument and close the stream after its use and before returning.<R> R processStackStream(Function<StackStream, R> fun) {StackStream stackStream = new StackStream(Thread.currentThread()); // bias the stack stream on the current thread// the current thread is checked before doing something on the stream. try {return fun.apply(stackStream); // the stack stream is visible by the user, but it can not use it in another thread} finally {stackStream.close(); // set a flag saying that you can't access to the underlying stack stream anymore // the flag doesn't need to be volatile if the current thread is checked first}}
Good idea. I'll explore this. thanks Mandy
