当前位置: 首页>>代码示例>>Java>>正文


Java ThreadHelper类代码示例

本文整理汇总了Java中org.openyu.commons.thread.ThreadHelper的典型用法代码示例。如果您正苦于以下问题:Java ThreadHelper类的具体用法?Java ThreadHelper怎么用?Java ThreadHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ThreadHelper类属于org.openyu.commons.thread包,在下文中一共展示了ThreadHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doRun

import org.openyu.commons.thread.ThreadHelper; //导入依赖的package包/类
/**
 * 來自於BaseRunnable.run,緒處理
 */
@Override
protected void doRun() throws Exception {
	for (;;) {
		try {
			if (isShutdown()) {
				break;
			}
			//
			execute();
			ThreadHelper.sleep(listenMills);
		} catch (Exception ex) {
			// ex.printStackTrace();
		}
	}
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:19,代码来源:LoopQueueSupporter.java

示例2: waitConnect

import org.openyu.commons.thread.ThreadHelper; //导入依赖的package包/类
/**
 * socket未連上時,最多等待幾毫秒
 * 
 * @param socketChannel
 * @param waitMillis
 * @return
 */
public static boolean waitConnect(SocketChannel socketChannel, long waitMillis) {
	boolean result = false;
	long beg = System.currentTimeMillis();
	long end = 0;
	//
	result = finishConnect(socketChannel);
	//
	while (!result) {
		end = System.currentTimeMillis();
		//
		if ((end - beg) >= waitMillis) {
			break;
		}
		//
		ThreadHelper.sleep(1 * 1000);// 間隔一秒
		result = finishConnect(socketChannel);
		// System.out.println((end - beg));
	}
	return result;
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:28,代码来源:NioHelper.java

示例3: start

import org.openyu.commons.thread.ThreadHelper; //导入依赖的package包/类
@Test
@BenchmarkOptions(benchmarkRounds = 1, warmupRounds = 0, concurrency = 1)
public void start() {
	StopWatch sw = new StopWatch();
	sw.start("A Task");
	ThreadHelper.sleep(1000);
	sw.stop();
	//
	sw.start("B Task");
	ThreadHelper.sleep(1500);
	sw.stop();
	//
	sw.start("C Task");
	ThreadHelper.sleep(2000);
	sw.stop();
	//
	sw.printResult();
	//
	LOGGER.info(sw.prettyPrint());
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:21,代码来源:StopWatchTest.java

示例4: checkExpired

import org.openyu.commons.thread.ThreadHelper; //导入依赖的package包/类
@Test
@BenchmarkOptions(benchmarkRounds = 1, warmupRounds = 0, concurrency = 1)
// round: 0.71 [+- 0.00], round.block: 0.00 [+- 0.00], round.gc: 0.00 [+-
// 0.00], GC.calls: 0, GC.time: 0.00, time.total: 0.71, time.warmup: 0.00,
// time.bench: 0.71
public void checkExpired() {
	// 建構key
	int count = 10;
	for (int i = 0; i < count; i++) {
		AuthKey authKey = authKeyService.createAuthKey();
		authKey.setAliveMills(0L);// 0=表都到期了
		// 加入到mem上
		authKeyService.addAuthKey(authKey.getId(), authKey);
		ThreadHelper.sleep(50);
	}
	int size = authKeyService.getAuthKeys().size();
	System.out.println(size);
	assertEquals(10, size);

	// 檢查key,應該都到期了
	((AuthKeyServiceImpl) authKeyService).checkExpired();
	//
	size = authKeyService.sizeOfAuthKey();
	System.out.println(size);
	assertEquals(0, size);
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:27,代码来源:AuthKeyServiceImplTest.java

示例5: mockOpenCacheWithMultiThread

import org.openyu.commons.thread.ThreadHelper; //导入依赖的package包/类
@Test
@BenchmarkOptions(benchmarkRounds = 1, warmupRounds = 0, concurrency = 1)
public void mockOpenCacheWithMultiThread() {
	for (int i = 0; i < 5; i++) {
		Thread thread = new Thread(new Runnable() {
			public void run() {
				try {
					mockOpenCache();
				} catch (Exception ex) {
				}
			}
		});
		thread.setName("T-" + i);
		thread.start();
		ThreadHelper.sleep(NumberHelper.randomInt(100));
	}
	//
	ThreadHelper.sleep(5 * 1000);
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:20,代码来源:SoftReferenceCacheFactoryImplTest.java

示例6: insert

import org.openyu.commons.thread.ThreadHelper; //导入依赖的package包/类
@Test
@BenchmarkOptions(benchmarkRounds = 1, warmupRounds = 0, concurrency = 1)
// no aop
// round: 1.45 [+- 0.00], round.block: 0.00 [+- 0.00], round.gc: 0.00 [+-
// 0.00], GC.calls: 0, GC.time: 0.00, time.total: 1.45, time.warmup: 0.00,
// time.bench: 1.45
public void insert() {
	// 隨機
	CatImpl cat = randomCat();
	//
	Serializable pk = catService.insert(cat);
	printInsert(pk);
	assertNotNull(pk);
	//
	// CatImpl foundEntity = catService.find(CatImpl.class, cat.getSeq());
	// printFind(foundEntity);
	// assertCat(cat, foundEntity);

	//
	ThreadHelper.sleep(3 * 1000);
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:22,代码来源:CatServiceImplTest.java

示例7: insertCat

import org.openyu.commons.thread.ThreadHelper; //导入依赖的package包/类
@Test
@BenchmarkOptions(benchmarkRounds = 1, warmupRounds = 0, concurrency = 1)
// @Aspect
// pointcut=>class
// round: 1.47 [+- 0.00], round.block: 0.00 [+- 0.00], round.gc: 0.00 [+-
// 0.00], GC.calls: 1, GC.time: 0.06, time.total: 1.47, time.warmup: 0.00,
// time.bench: 1.47

// pointcut=>insterface
// round: 1.37 [+- 0.00], round.block: 0.00 [+- 0.00], round.gc: 0.00 [+-
// 0.00], GC.calls: 1, GC.time: 0.03, time.total: 1.37, time.warmup: 0.00,
// time.bench: 1.37
public void insertCat() {
	CatImpl cat = randomCat();
	// CatAspect處理log
	Serializable pk = catService.insertCat(cat);
	printInsert(pk);
	assertNotNull(pk);
	//
	ThreadHelper.sleep(3 * 1000);
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:22,代码来源:CatServiceImplTest.java

示例8: submit

import org.openyu.commons.thread.ThreadHelper; //导入依赖的package包/类
@Test
@BenchmarkOptions(benchmarkRounds = 1, warmupRounds = 0, concurrency = 1)
public void submit() {
	Runner runner = new Runner();
	threadService.submit(runner);// t1
	threadService.submit(runner);// t2
	threadService.submit(runner);// t3
	threadService.submit(runner);// t4
	threadService.submit(runner);// t5
	threadService.submit(runner);// t6
	threadService.submit(runner);// t7
	threadService.submit(runner);// t8
	threadService.submit(runner);// t9
	threadService.submit(runner);// t10
	//
	ThreadHelper.sleep(3 * 1000);
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:18,代码来源:ThreadServiceImplTest.java

示例9: mocktStartWithMultiThread

import org.openyu.commons.thread.ThreadHelper; //导入依赖的package包/类
@Test
public void mocktStartWithMultiThread() {
	// 80,110,130,290
	// mem=512m 735
	// mem=768m 950
	// client -> slave1:10300
	for (int i = 0; i < 500; i++) {
		Thread thread = new Thread(new Runnable() {
			public void run() {
				mockStart();
			}
		});
		thread.setName("T-" + i);
		thread.start();
		//
		ThreadHelper.sleep(50);
	}
	//
	ThreadHelper.sleep(5 * 60 * 1000);
}
 
开发者ID:mixaceh,项目名称:openyu-socklet,代码行数:21,代码来源:JavaConnectorImplTest.java

示例10: putOne

import org.openyu.commons.thread.ThreadHelper; //导入依赖的package包/类
/**
 * 單擊獎勵放入包包
 */
@Test
@BenchmarkOptions(benchmarkRounds = 1, warmupRounds = 0, concurrency = 1)
public void putOne() {
	Role role = mockRole();
	// BagInfo bagInfo = role.getBagInfo();
	role.setLevel(25);// 等級
	role.setGold(10000 * 10000L);// 1e
	role.setVipType(VipType._2);// vip
	//
	WuxingInfo wuxingInfo = role.getWuxingInfo();
	wuxingInfo.getAwards().put("T_POTION_HP_G001", 1);
	//
	PutResult result = wuxingService.putOne(true, role, "T_POTION_HP_G001", 1);
	System.out.println(result);
	assertNotNull(result);
	assertEquals(1, result.getAwards().size());
	//
	ThreadHelper.sleep(3 * 1000L);
}
 
开发者ID:mixaceh,项目名称:openyu-mix,代码行数:23,代码来源:WuxingServiceImplTest.java

示例11: increaseGold

import org.openyu.commons.thread.ThreadHelper; //导入依赖的package包/类
@Test
@BenchmarkOptions(benchmarkRounds = 1, warmupRounds = 0, concurrency = 1)
public void increaseGold() {
	Role role = mockRole();// accountId=TEST_ACCOUNT,roleId=TEST_ROLE
	role.setGold(10L);
	//
	long result = 0L;
	result = roleService.increaseGold(true, role, 100L, GoldType.SHOP_SELL);

	System.out.println(result);
	assertEquals(110L, role.getGold());
	//
	result = roleService.increaseGold(true, role, 0L, GoldType.SHOP_SELL);
	System.out.println(result);
	assertEquals(110L, role.getGold());
	//
	ThreadHelper.sleep(3 * 1000);
}
 
开发者ID:mixaceh,项目名称:openyu-mix,代码行数:19,代码来源:RoleServiceImplTest.java

示例12: decreaseGold

import org.openyu.commons.thread.ThreadHelper; //导入依赖的package包/类
@Test
@BenchmarkOptions(benchmarkRounds = 1, warmupRounds = 0, concurrency = 1)
// round: 0.78 [+- 0.00], round.block: 0.00 [+- 0.00], round.gc: 0.00 [+-
// 0.00], GC.calls: 0, GC.time: 0.00, time.total: 0.78, time.warmup: 0.00,
// time.bench: 0.78
public void decreaseGold() {
	Role role = mockRole();// accountId=TEST_ACCOUNT,roleId=TEST_ROLE
	role.setGold(100L);
	//
	long result = 0L;
	// 會發訊息,會有log
	result = roleService.decreaseGold(true, role, 50L, GoldType.SASANG_PLAY);
	System.out.println(result);
	assertEquals(50L, role.getGold());
	//
	result = roleService.decreaseGold(true, role, 0L, GoldType.SASANG_PLAY);
	System.out.println(result);
	assertEquals(50L, role.getGold());
	//
	ThreadHelper.sleep(3 * 1000);
}
 
开发者ID:mixaceh,项目名称:openyu-mix,代码行数:22,代码来源:RoleServiceImplTest.java

示例13: changeGold

import org.openyu.commons.thread.ThreadHelper; //导入依赖的package包/类
@Test
@BenchmarkOptions(benchmarkRounds = 1, warmupRounds = 0, concurrency = 1)
// round: 0.46 [+- 0.00], round.block: 0.00 [+- 0.00], round.gc: 0.00 [+-
// 0.00], GC.calls: 0, GC.time: 0.00, time.total: 0.46, time.warmup: 0.00,
// time.bench: 0.46
public void changeGold() {
	Role role = mockRole();
	role.setGold(500L);
	long result = 0L;
	//
	// 會發訊息
	result = roleService.changeGold(true, role, 500L, ActionType.INCREASE, GoldType.SHOP_SELL);
	System.out.println(result);
	assertEquals(1000L, role.getGold());
	//
	result = roleService.changeGold(true, role, -1 * 100L, ActionType.DECREASE, GoldType.SASANG_PLAY);
	System.out.println(result);
	assertEquals(900L, role.getGold());

	//
	result = roleService.changeGold(true, role, 0, ActionType.DECREASE, GoldType.SASANG_PLAY);
	System.out.println(result);
	assertEquals(900L, role.getGold());
	//
	ThreadHelper.sleep(3 * 1000);
}
 
开发者ID:mixaceh,项目名称:openyu-mix,代码行数:27,代码来源:RoleServiceImplTest.java

示例14: changeFame

import org.openyu.commons.thread.ThreadHelper; //导入依赖的package包/类
@Test
@BenchmarkOptions(benchmarkRounds = 1, warmupRounds = 0, concurrency = 1)
// round: 1.56 [+- 0.00], round.block: 0.00 [+- 0.00], round.gc: 0.00 [+-
// 0.00], GC.calls: 0, GC.time: 0.00, time.total: 1.56, time.warmup: 0.02,
// time.bench: 1.56
public void changeFame() {
	Role role = mockRole();
	role.setFame(100);
	int result = 0;
	// 會發訊息
	result = roleService.changeFame(true, role, 50);
	System.out.println(result);
	assertEquals(150, role.getFame());
	//
	result = roleService.changeFame(true, role, (-1) * 10);
	System.out.println(result);
	assertEquals(140, role.getFame());
	//
	result = roleService.changeFame(true, role, 0);
	System.out.println(result);
	assertEquals(140, role.getFame());
	//
	ThreadHelper.sleep(3 * 1000);
}
 
开发者ID:mixaceh,项目名称:openyu-mix,代码行数:25,代码来源:RoleServiceImplTest.java

示例15: decreaseItemWithUniqueId

import org.openyu.commons.thread.ThreadHelper; //导入依赖的package包/类
@Test
@BenchmarkOptions(benchmarkRounds = 1, warmupRounds = 0, concurrency = 1)
// round: 0.71 [+- 0.00], round.block: 0.00 [+- 0.00], round.gc: 0.00 [+-
// 0.00], GC.calls: 0, GC.time: 0.00, time.total: 0.71, time.warmup: 0.00,
// time.bench: 0.71
public void decreaseItemWithUniqueId() {
	final String THING_ID = "T_POTION_HP_G001";
	DecreaseItemResult result = null;
	//
	Role role = mockRole();
	// 道具數量=10,最大堆疊數量=100,有120個道具
	BagInfo bagInfo = BagInfoImplTest.mockBagInfoWithSameThing(THING_ID);
	bagInfo.removeItem(0, 0);// 移除1個道具
	role.setBagInfo(bagInfo);
	Item item = bagInfo.getItem(0, 1);
	//
	result = itemService.decreaseItemWithUniqueId(true, role, item.getUniqueId(), 1);
	System.out.println(result);
	// 沒有錯誤
	assertNotNull(result);
	//
	ThreadHelper.sleep(3 * 1000);
}
 
开发者ID:mixaceh,项目名称:openyu-mix,代码行数:24,代码来源:ItemServiceImplTest.java


注:本文中的org.openyu.commons.thread.ThreadHelper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。