创建线程实例

2015-01-01 lingzixu

ZiJinLocker
package com.zjft.dblock.test;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.log4j.PropertyConfigurator;

import com.zjft.dblock.core.JobLockSupport;
import com.zjft.dblock.core.impl.JobLockSupportImpl;

public class DBLockTest {

public static void main(String[] args) throws Exception{
PropertyConfigurator.configure("./log4j.properties");
Log log = LogFactory.getLog(DBLockTest.class);
//log.info("begin init app.");
//DbConnectionNoContainer.connectionAuth() ;

 //JobLockSupport jobLockSupport = JobLockSupportImpl.getInstance();
 //log.info("JobLockSupportImpl="+ jobLockSupport.hashCode());
//jobLockSupport.startCheckServer();
//jobLockSupport.setBlockingFlag(true);

 Thread exThread_1 = new Thread(new TestThread4Concurrent());
exThread_1.setName("ex-Thread-1");
exThread_1.start();

// log.info("entering ex-Thread thread");
Thread.sleep(3000);

 Thread exThread_2 = new Thread(new TestThread4Concurrent());
exThread_2.setName("ex-Thread-2");
exThread_2.start();

// for (int i = 0; i < 1000; i++) {
// try {
// log.info("getDbLockOne"+i+":"+jobLockSupport.getDbLock("JOB_ACCESS"));
// int randomNum = (int)(Math.random()*5+1);
// Thread.sleep(randomNum*1000);
//} catch (Exception e) {
//// TODO Auto-generated catch block
//e.printStackTrace();
//}finally{
//jobLockSupport.releaseDbLock("JOB_ACCESS");
//}
//}

// jobLockSupport.closeCheck();

 //log.info("Game0 is over!");




}
}