File tree 2 files changed +7
-8
lines changed
main/java/com/thealgorithms/sorts
test/java/com/thealgorithms/sorts 2 files changed +7
-8
lines changed Original file line number Diff line number Diff line change 1
1
package com .thealgorithms .sorts ;
2
2
3
- /**
3
+ /*
4
4
* @author Aiswarya PM (https://github.com/aishuarya)
5
5
* The SleepSort class demonstrates the Sleep Sort algorithm.
6
6
* Sleep Sort is a sorting algorithm that works by leveraging the concurrency of threads.
17
17
import java .util .ArrayList ;
18
18
import java .util .Collections ;
19
19
20
- public class SleepSort {
20
+ class SleepSort {
21
21
22
22
public static void sleepSort (ArrayList <Integer > array ) {
23
23
ArrayList <Thread > threads = new ArrayList <>();
24
24
25
25
for (int numbers : array ) {
26
26
Thread thread = new Thread (() -> {
27
27
try {
28
- Thread .sleep (numbers ); // Sleep for 'num' milliseconds
29
- System .out .print (numbers + " " ); // Print the number after sleeping
28
+ Thread .sleep (numbers ); // Sleep for 'num' milliseconds
29
+ System .out .print (numbers + " " ); // Print the number after sleeping
30
30
} catch (InterruptedException e ) {
31
31
e .printStackTrace ();
32
32
}
Original file line number Diff line number Diff line change 1
1
package com .thealgorithms .sorts ;
2
2
3
- import org .junit .jupiter .api .Test ;
3
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
4
+ import static org .junit .jupiter .api .Assertions .assertTrue ;
4
5
import java .io .ByteArrayOutputStream ;
5
6
import java .io .PrintStream ;
6
7
import java .util .ArrayList ;
7
8
import java .util .Collections ;
8
9
import java .util .List ;
9
- import static org .junit .jupiter .api .Assertions .assertEquals ;
10
- import static org .junit .jupiter .api .Assertions .assertTrue ;
11
-
10
+ import org .junit .jupiter .api .Test ;
12
11
public class SleepSortTest {
13
12
14
13
// Method to capture the output of the SleepSort
You can’t perform that action at this time.
0 commit comments