频道直达 - 专题 - 新闻 - 技巧 - 组网 - 开发 - 安全 - web编程 - 图像 - 操作系统 - 数据库 - 教育 - 旅游 - 健康 - 时尚 - 驱动 - 软件 - 游戏 - 多媒体 - ERP - 讨论组

试试jdk1.5

来源: 作者: 出处:巧巧读书 2006-05-11 进入讨论组
  • 关 键 词:
  • java

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) {//循环
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);//静态导入
System.out.printf("%2$s\t%1$d\n",new Integer(1),"str");//printf
for (firstEnum fe:firstEnum.values()) {
System.out.println(fe);
} //并发
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 {
}

http://www.qqread.com/java/2006/05/u306109002.html进入讨论组讨论。
收藏此文】【 】【打印】【关闭
较早的文章:我见过的最长的表达式

较新的文章:深入equals方法
相关图文阅读
频道图文推荐
健 康 咨 询
时 尚 咨 询
巧巧读书宗旨
相关专题
讨论组问题推荐
站内各频道最新更新文档
站内最新制作专题
热门关键字导读
Photoshop教 程照片处理 照片制作 PS快捷键 抠图
计 算 机 故 障XP系统修复
艺 术 与 设 计设计 流媒体 设计欣赏 边框
计 算 机 安 全ARP
站内频道文章精选
巧巧电脑频道编辑信箱  告诉我们您想看的专题或文章