-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThird_Half.java
More file actions
44 lines (34 loc) · 942 Bytes
/
Third_Half.java
File metadata and controls
44 lines (34 loc) · 942 Bytes
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
import java.util.ArrayList;
import java.util.Random;
public class Third_Half implements Runnable{
ArrayList<Integer> Array = new ArrayList<>();
int range, bound;
Third_Half(int range, int bound){
this.range = range;
this.bound = bound;
}
@Override
public void run() {
Random value = new Random();
int Count = 0;
while( Count < range/2 ){
int temp = value.nextInt(range,bound);
if(is_Unique(Array, Count, temp)){
Array.add(temp);
Count++;
}
}
System.out.println("Thread 3 Complete");
}
boolean is_Unique(ArrayList<Integer> Array, int Size, int val){
for(int i=0; i<Size; i++){
if(Array.get(i) == val ){
return false;
}
}
return true;
}
public ArrayList<Integer> get_Array(){
return Array;
}
}