ejb与java序列化(2) 测试代码[Java编程]
本文“ejb与java序列化(2) 测试代码[Java编程]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:
接上篇,有爱好的朋友可以直接拿我的测试代码自行测试,请自行改正诸如线程数,履行时间,序列化的数据量大小等参数.假如想尝试做thread dump,可以翻开相关的两个注释,会更便利一些,代码中都有呼应的注释可供参考.
测试代码以下:
package test;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.ArrayList;
public class Test implements Runnable {
//Notice! set the three test parameter to what you want first
/**
* thread count to run test
*/
private static final int THREAD_COUNT = 50;
/**
* time in seconds to run test
*/
private static final long TEST_TIME_SECOND = 1 * 30;
/**
* during test, we serialize a Data instance with an ArrayList that contains DataItem instance.
* This is to set how many DataItem in the ArrayList.
*/
private static final long ITEMS_COUNT_IN_TEST_OBJECT = 1000;
private static int finishedCount = 0;
private static boolean needStop = false;
private static Object needStopLock = new Object();
private static Object finishedCountLock = new Object();
private static boolean isNeedStop() {
synchronized (needStopLock) {
return needStop;
}
}
private static void setNeedStop() {
synchronized (needStopLock) {
needStop = true;
}
}
private static void addFinisedCount() {
synchronized (finishedCountLock) {
finishedCount++;
}
}
以上是“ejb与java序列化(2) 测试代码[Java编程]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
本文地址: | 与您的QQ/BBS好友分享! |