JAVA线程池管理及分布式HADOOP调度框架搭建
来源:互联网 发布:网络机柜理线 编辑:程序博客网 时间:2024/05/29 09:18
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
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
packagethread;
importjava.util.Vector;
publicclass OneMain {
publicstaticvoid main(String[] args)throwsInterruptedException{
Vector<Integer> list =new Vector<Integer>(100);
for(int i =0; i <100; i++){
list.add(i);
}
long start =System.currentTimeMillis();
while(list.size()>0){
int val = list.remove(0);
Thread. sleep(100);//模拟处理
System. out.println(val);
}
long end =System.currentTimeMillis();
System. out.println("消耗 "+(end - start)+" ms");
}
// 消耗 10063 ms
}
importjava.util.Vector;
publicclass OneMain {
publicstaticvoid main(String[] args)throwsInterruptedException{
Vector<Integer> list =new Vector<Integer>(100);
for(int i =0; i <100; i++){
list.add(i);
}
long start =System.currentTimeMillis();
while(list.size()>0){
int val = list.remove(0);
Thread. sleep(100);//模拟处理
System. out.println(val);
}
long end =System.currentTimeMillis();
System. out.println("消耗 "+(end - start)+" ms");
}
// 消耗 10063 ms
}
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
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
packagethread;
importjava.util.Vector;
importjava.util.concurrent.CountDownLatch;
publicclass MultiThread extendsThread{
static Vector<Integer> list =new Vector<Integer>(100);
static CountDownLatch count =new CountDownLatch(10);
publicvoid run(){
while(list.size()>0){
try{
int val = list.remove(0);
System.out.println(val);
Thread.sleep(100);//模拟处理
}catch(Exception e){
// 可能数组越界,这个地方只是为了说明问题,忽略错误
}
}
count.countDown();// 删除成功减一
}
publicstaticvoid main(String[] args)throwsInterruptedException{
for(int i =0; i <100; i++){
list.add(i);
}
long start =System.currentTimeMillis();
for(int i =0; i <10; i++){
new MultiThread().start();
}
count.await();
long end =System.currentTimeMillis();
System.out.println("消耗 "+(end - start)+" ms");
}
// 消耗 1001 ms
}
importjava.util.Vector;
importjava.util.concurrent.CountDownLatch;
publicclass MultiThread extendsThread{
static Vector<Integer> list =new Vector<Integer>(100);
static CountDownLatch count =new CountDownLatch(10);
publicvoid run(){
while(list.size()>0){
try{
int val = list.remove(0);
System.out.println(val);
Thread.sleep(100);//模拟处理
}catch(Exception e){
// 可能数组越界,这个地方只是为了说明问题,忽略错误
}
}
count.countDown();// 删除成功减一
}
publicstaticvoid main(String[] args)throwsInterruptedException{
for(int i =0; i <100; i++){
list.add(i);
}
long start =System.currentTimeMillis();
for(int i =0; i <10; i++){
new MultiThread().start();
}
count.await();
long end =System.currentTimeMillis();
System.out.println("消耗 "+(end - start)+" ms");
}
// 消耗 1001 ms
}
- JAVA线程池管理及分布式HADOOP调度框架搭建
- JAVA线程池管理及分布式HADOOP调度框架搭建
- Java线程池管理及分布式Hadoop调度框架搭建
- Java线程池管理及分布式Hadoop调度框架搭建
- Java线程池管理及分布式Hadoop调度框架搭建
- Java线程池管理及分布式Hadoop调度框架搭建
- JAVA线程池管理及分布式HADOOP调度框架搭建
- JAVA线程池管理及分布式HADOOP调度框架搭建
- Java线程池管理及分布式Hadoop调度框架搭建
- Hadoop分布式框架搭建
- java线程池管理以及分布式
- 搭建hadoop分布式文件管理系统(HDFS)
- hadoop伪分布式ha框架搭建
- JAVA 线程优化及线程池管理
- JAVA 线程优化及线程池管理
- Hadoop纹为分布式搭建及常见问题
- 分布式调度框架TBSchedule
- Java(线程的生命周期及调度)
- 详解 Qt 动态插件编写要点
- NSFileManager
- 前端httpd+heepalived加后端heartbeat+nfs+drbd实现httpd服务的高效应用及资源统一管理
- 生成jar
- MT(Multi-Touch) Protocol (1)
- JAVA线程池管理及分布式HADOOP调度框架搭建
- 【黑马程序员】string 类stringbuffer类以及它们的一些方法
- json cloud
- Java的原生数据类型(8种)
- Axure 创建弹出框
- C#取得当前进程所有打开的窗体
- Android uiautomator 学习笔记
- onNewIntent
- html隐藏式菜单