ITeye博客

tobemoved的博客

tobemoved · 共 9 篇文章

JAVA的小圈套

public class Test { static String s = "abc"; { s.charAt( 0); System.out.println(" B"); } static { System.out.println(" A"); s = null; } public Test() { s = "def"; System.out.println(" C"); } public static void main(String[] args) { System.out.println(" E"); System.out.println(new Test().s); System.…

2008-07-11 10:13 · java代码 · 评论(0)

接口的的作用(注意第13行)

interface B { String getS(); } class A2 implements B { public String getS() { return "A2"; } } public class A implements B { public String getS() { return "A"; } static void show(B b) { System.out.println( b.getS()); } public static void main(String[] args) { A2 a2 = new A2(); A a = new A(); show(a…

2008-07-09 09:45 · java代码 · 评论(0)

用DOM读取XML文件的案例

//用DOM读取XML public class A { Document document = null; public void t() { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); try { DocumentBuilder builder = factory.newDocumentBuilder(); document = builder.parse(configPath); Node rootNode = document.getFirstChild(); System.out.pr…

2008-07-09 09:16 · java代码 · 评论(0)

关于实现简单线程池的改写

import java.util.*; import java.lang.reflect.Array; /** * Created by IntelliJ IDEA. * User: Administrator * Date: 2008-7-7 * Time: 9:07:56 * To change this template use File | Settings | File Templates. */ public class ThreadPool { //初始化空闲队列以及工作队列 List freeThreads = new ArrayList(); List runThreads…

2008-07-08 10:30 · java代码 · 评论(0)

java写的简单线程池

import java.util. ; import java.io. ; import java.net.*; //线程池类,创建处于使用中和空闲中的进程队列 class ThreadPool{ private Vector freeThreads = new Vector(); private Vector inUseThreads = new Vector();//Vetcor对象 private static int value = 100;//线程池的最大并发线程数 public ThreadPool(){ fillpool(value); } private void fillp…

2008-07-08 10:26 · java代码 · 评论(0)

线程池的实现例子2

** 线程池是一组线程,限制执行任务的线程数 */ public class ThreadPool extends ThreadGroup { private boolean isAlive; private LinkedList taskQueue; private int threadID; private static int threadPoolID; /** 创建新的线程池,numThreads是池中的线程数 */ public ThreadPool(int numThreads) { super("ThreadPool-" + (threadPoolID++)); setDaem…

2008-07-08 10:25 · java代码 · 评论(0)

线程池的实现例子1

import java.util.LinkedList; import java.util.List; public class ThreadPool ...{ private static ThreadPool instance = null; // 优先级低 public static final int PRIORITY_LOW = 0; // 普通 public static final int PRIORITY_NORMAL = 1; // 高 public static final int PRIORITY_HIGH = 2; // 用以保存空闲连接 private List _…

2008-07-08 10:22 · java代码 · 评论(4)

有关于Arrays的一些尝试

import java.util.Arrays; import java.util.ArrayList; import java.awt.*; /** Created by IntelliJ IDEA. User: Administrator Date: 2008-7-7 Time: 14:45:52 To change this template use File | Settings | File Templates. */ public class oldtest{ int a={2,4,6,3,1,9,67}; int b={2,4,6,3,1,9,67}; public stati…

2008-07-08 10:20 · java代码 · 评论(0)

规范的流方法之复制文件代码

import java.util.ArrayList; import java.util.Vector; import java.util.Map; import java.util.Hashtable; import java.io.*; /** Created by IntelliJ IDEA. User: Administrator Date: 2008-7-2 Time: 13:40:28 To change this template use File | Settings | File Templates. */ public class Newone { public stat…

2008-07-08 09:58 · java代码 · 评论(0)