Administrator
2022-09-14 58d006e05dcf2a20d0ec5367dd03d66a61db6849
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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();
        }
    }
}