forked from zaiyunduan123/Java-Summarize
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayListTest.java
More file actions
47 lines (35 loc) · 1.06 KB
/
ArrayListTest.java
File metadata and controls
47 lines (35 loc) · 1.06 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
package jdk;
import java.util.*;
import static java.lang.Runtime.getRuntime;
/**
* Created by jiangyunxiong on 2018/4/30.
*/
public class ArrayListTest {
public static void main(String[] args) {
List<Integer> list = new ArrayList<>();
list.add(1);
list.add(2);
list.add(3);
List<Integer> synList = Collections.synchronizedList(list);
synchronized (list) {
Iterator<Integer> iterator = synList.iterator();
while (iterator.hasNext()) {
System.out.println(iterator.next());
}
}
int[] i = {1, 1, 1, 1};
Arrays.sort(i);
Collections.sort(list, new Comparator() {
@Override
public int compare(Object o1, Object o2) {
return 0;
}
@Override
public boolean equals(Object obj) {
return false;
}
});//底层调用Arrays,sort();
int i1 = Runtime.getRuntime().availableProcessors();
System.out.println("cpu:" + i1);
}
}