package com.hi.test;
public class Tools {
// 如果数据存在 共享的 ,那么为了保证数据的完全性, 需要使用同步
// 如果数据不存在的 共享的问题,那么可以使用 异步, 使用并发执行
public static ThreadLocal<String> t1 = new ThreadLocal<String>();
public static ThreadLocal<Integer> t = new ThreadLocal<Integer>();
public static int total = 1;
public static Object lock = new Object();
public static void main(String[] args) {
new ThreadA(lock).start();
new ThreadB(lock).start();
new ThreadSyncA().start();
new ThreadSyncB().start();
synchronized (lock)
{
for(int i=0;i<100;i++)
{
t1.set("Main =