package com.mandi.fendan.util; public class Runtest implements Runnable{ @Override public void run() { // System.err.println(Thread.currentThread().getName()); // synchronized (new Object()) { String str=DBchecksingleton.setDbc(Thread.currentThread().getName(), false); if(str.equals(Thread.currentThread().getName())){ System.err.println("A:::::"+str+"::::时间:::"+System.nanoTime()); String crd=DBchecksingleton.setDbc(Thread.currentThread().getName(), true); System.err.println(str+"B:::::"+crd+"::::时间:::"+System.nanoTime()); }else{ String rrr=DBchecksingleton.setDbc(Thread.currentThread().getName(), true); if(rrr==null){ System.err.println("C:::::"+Thread.currentThread().getName()+"::::时间:::"+System.nanoTime()); }else{ System.err.println(rrr+"::::D:::::"+Thread.currentThread().getName()+"::::时间:::"+System.nanoTime()); } // System.err.println("ddd:::::"+str); // System.err.println("fff:::::"+rrr); } // } //新建对象Lockerp放当前erp数据库有没有修改操作 // lockerp是一个map key放入dbsign:放入Connection //所有的修改erp操作都事先需要判断一下当前值Lockerp能否找到 //放入Lockerp当前操作erp的值 //调用同步线程Runerp:不知道有多个请求的时候在线程后面排队的时间会不会太长 //同步线程传入参数Connection //如果Connection相等 休眠 //如果Connection不相等 而且 //Runerp操作: //Runerp返回结果 } public static void main(String[] args){ Runtest t=new Runtest(); for (int i = 1; i < 110; i++) { new Thread(t,"name:"+i).start(); } } }