Skip to content

Instantly share code, notes, and snippets.

@findepi
Created March 4, 2016 22:23
Show Gist options
  • Save findepi/5dffe9e251321fe0aac7 to your computer and use it in GitHub Desktop.
Save findepi/5dffe9e251321fe0aac7 to your computer and use it in GitHub Desktop.
import java.util.Collections;
/**
* @author piofin <piotr.findeisen@gmail.com>
* @since Mar 4, 2016
*/
public class ParallelStreamReusesCaller {
public static void main(String[] args) {
Thread main = Thread.currentThread();
Collections.nCopies(1000, 0)
.parallelStream()
.forEach(i -> {
System.out.println("Current thread = " + Thread.currentThread());
if (Thread.currentThread() == main) {
System.exit(0);
}
});
System.out.println("Did not terminate?");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment