Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.stream.IntStream;
- class Threads {
- public static void main(String... args) {
- IntStream
- .range(0, 10)
- .mapToObj(i -> new Thread(() -> System.out.println(Thread.currentThread().getName())))
- .forEach(thread -> thread.start());
- }
- }
- // Output:
- /*
- Thread-0
- Thread-3
- Thread-1
- Thread-2
- Thread-4
- Thread-7
- Thread-5
- Thread-6
- Thread-9
- Thread-8
- */
Add Comment
Please, Sign In to add comment