[Neta] Sleep Sort in Java

http://qiita.com/lovee/items/9701151633d61e7ed4e3 http://qiita.com/takustaqu/items/412d6c36534b1145a024

Because there was, it is a Java version.

int[] array = {5, 3, 6, 3, 6, 3, 1, 4, 7};

 new ForkJoinPool(array.length).submit(() -> {
	IntStream.of(array).parallel().forEach(n -> {

		try {
			TimeUnit.SECONDS.sleep(n);
			System.out.println(n);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	});
}).get();

/*output:
1
3
3
3
4
5
6
6
7
*/

Recommended Posts

[Neta] Sleep Sort in Java
[java] sort in list
java bubble sort
Partization in Java
Changes in Java 11
Rock-paper-scissors in Java
java selection sort
java insertion sort
Pi in Java
FizzBuzz in Java
Implemented basic search / sort algorithm in Java
Programming with direct sum types in Java (Neta)
Read JSON in Java
Make Blackjack in Java
Constraint programming in Java
Put java8 in centos7
NVL-ish guy in Java
Combine arrays in Java
"Hello World" in Java
Callable Interface in Java
Comments in Java source
Azure functions in java
Format XML in Java
Java Japanese (Kanji) Sort
Simple htmlspecialchars in Java
Boyer-Moore implementation in Java
Hello World in Java
Use OpenCV in Java
webApi memorandum in java
Type determination in Java
Ping commands in Java
Various threads in java
Heapsort implementation (in java)
Zabbix API in Java
ASCII art in Java
Compare Lists in Java
POST JSON in Java
Express failure in Java
Create JSON in Java
Date manipulation in Java 8
What's new in Java 8
Use PreparedStatement in Java
What's new in Java 9,10,11
Parallel execution in Java
Initializing HashMap in Java
Sort Map values in ascending key order in Java TreeMap
Try using RocksDB in Java
Avoid Yubaba's error in Java
Get EXIF information in Java
Save Java PDF in Excel
[Java, stream] Sort object list in Japanese by property name
Edit ini in Java: ini4j
Java history in this world
Let Java segfault in 6 lines
Try calling JavaScript in Java
Try developing Spresense in Java (1)
Try functional type in Java! ①
I made roulette in Java.
Create hyperlinks in Java PowerPoint
Implement two-step verification in Java
Refactoring: Make Blackjack in Java