![](https://csdnimg.cn/release/download_crawler_static/85860793/bg1.jpg)
Java 8
java.lang.IllegalStateException: stream has already been operated upon or closed
5.7.3
4
6
“
Lambda
fork
Java 8
API
Spliterator
BlockingQueues
Futures
StreamForker
StreamForker
C-1
StreamForker
public class StreamForker<T> {
1
2
3
4
5
private final Stream<T> stream;
private final Map<Object, Function<Stream<T>, ?>> forks =
new HashMap<>();
public StreamForker(Stream<T> stream) {
this.stream = stream;
}
public StreamForker<T> fork(Object key, Function<Stream<T>, ?> f) {
forks.put(key, f);
return this;
}
public Results getResults() {
// To be implemented
}
}
fork
this
fork
6
7
q
Function
q
key
/
Map
fork
StreamForker
C-1
StreamForker