国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發(fā)設計 > 正文

試試jdk1.5

2019-11-17 06:17:53
字體:
供稿:網(wǎng)友

netbeans4.0beta2,手里的工具只有這個可以試試1.5了,1.5的concurrent也很強悍啊,很方便.

package jdk5;
import java.util.*;
import java.util.concurrent.*;
import static test.Constants.FIRST;
/** @author zzzhc
*/
public class Main {

public static enum firstEnum {one,two};
/** Creates a new instance of Main * */
PRivate Main() {
}

static int count = 0;
static Object lock = new Object();

/**
* @param args the command line arguments
*/
public static void main(String[] args) throws Exception{
List<String> list = new ArrayList<String>();//泛型
list.add("1");
list.add("first");
list.add("second");
for (String s:list) {//循環(huán)
System.out.println(s);
}
Vector v = new Vector();
v.add(23);//自動裝箱
v.add(32);
v.add(680);
for (int i:v) {//自動拆箱
System.out.println(i);
}
HashMap map = new HashMap();
map.put("key1",23);
System.out.println(map.get("key1"));
for (String i:map.keySet()) {
System.out.println(i);
}
System.out.println(FIRST);//靜態(tài)導入
System.out.printf("%2$s/t%1$d/n",new Integer(1),"str");//printf
for (firstEnum fe:firstEnum.values()) {
System.out.println(fe);
} //并發(fā)
Executor exec = Executors.newFixedThreadPool(5);
for (int i=0;
i<50;
i++) {
exec.execute(new Runnable() {
public void run() {
int cur;
synchronized (lock) {
cur = count++;
}
System.out.println(cur+"running...");
try {
Thread.sleep(2000);
}catch (Exception e) {
e.printStackTrace();
}
System.out.println(cur+"end...");
if (cur==49) {
System.exit(0);//else program can't exit
}
}
});
}
System.out.println("all started");
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
System.out.println("program end.");
}
});
}
}

@interface Enum {
}



發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 正镶白旗| 佛冈县| 盈江县| 儋州市| 宝鸡市| 杂多县| 太仓市| 龙口市| 崇信县| 庄浪县| 阳春市| 衡南县| 中山市| 伊金霍洛旗| 河西区| 怀安县| 佛山市| 青冈县| 东城区| 安阳县| 宁蒗| 额敏县| 金华市| 镇雄县| 达拉特旗| 梁山县| 清镇市| 台湾省| 庆安县| 晋中市| 龙江县| 长岭县| 泗阳县| 抚远县| 宁安市| 贵阳市| 甘南县| 阳江市| 庄浪县| 阜平县| 白河县|