- 浏览: 6642 次
- 性别:
- 来自: 上海
最近访客 更多访客>>
最新评论
-
helloguoxing:
//测试类的代码,我稍微改装了下。
package com ...
线程池的实现例子1 -
helloguoxing:
请重新输入:1、启动线程 2、关闭线程 3、查询当前线程池所有 ...
线程池的实现例子1 -
helloguoxing:
请重新输入:1、启动线程 2、关闭线程 3、查询当前线程池所有 ...
线程池的实现例子1 -
helloguoxing:
楼主这个线程池写的不错,我运行了下,优点略懂。
线程池的实现例子1
文章列表
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";
...
- 2008-07-11 10:13
- 浏览 619
- 评论(0)
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());
...
- 2008-07-09 09:45
- 浏览 380
- 评论(0)
//用DOM读取XML
public class A {
Document document = null;
public void t() {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder builder = factory.newDocumentBuilder();
document = builder.parse(configPath);
...
- 2008-07-09 09:16
- 浏览 820
- 评论(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();
...
- 2008-07-08 10:30
- 浏览 714
- 评论(0)
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(){
...
- 2008-07-08 10:26
- 浏览 950
- 评论(0)
**
线程池是一组线程,限制执行任务的线程数
*/
public class ThreadPool extends ThreadGroup {
private boolean isAlive;
private LinkedList taskQueue;
private int threadID;
private static int threadPoolID;
/**
创建新的线程池,numThreads是池中的线程数
*/
public ThreadPool(int numThreads) {
...
- 2008-07-08 10:25
- 浏览 938
- 评论(0)
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 ...
- 2008-07-08 10:22
- 浏览 882
- 评论(4)
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, ...
- 2008-07-08 10:20
- 浏览 591
- 评论(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 Newon ...
- 2008-07-08 09:58
- 浏览 748
- 评论(0)