-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSorter.java
More file actions
executable file
·49 lines (42 loc) · 1.02 KB
/
Copy pathSorter.java
File metadata and controls
executable file
·49 lines (42 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import java.util.Random;
public class Sorter extends Thread
{
private int[] num;
public static void main(String[] args)
{
int[] value = new int[10];
int i;
Random generator = new Random();
for (i = 0; i < value.length; i++)
value[i] = 1 + generator.nextInt(100);
Sorter mySorter = new Sorter(value);
try
{
mySorter.join();
}
catch(InterruptedException e)
{
}
mySorter.start();
for (i = 0; i < value.length;i++)
System.out.println(value[i]);
}
public Sorter(int[] num)
{
this.num = num;
}
public void run()
{
int i;
int j;
int temp;
for (i = 0; i < num.length - 1; j++)
for (j = i + 1; j < num.length; j++)
if (num[j] < num[i])
{
temp = num[i];
num[i] = num[j];
num[j] = temp;
}
}
}