package com.example; import java.util.Random; public class App { public static class MyRunnable1 implements Runnable { //ThreadLocal是一个线程局部变量 private ThreadLocal<String> threadlocal = new ThreadLocal<String>(); @Override public void run() { //…
为了凑字,把oracle文档里介绍ThreadLocal抄过来 public class ThreadLocal<T> extends Object This class provides thread-local variables. These variables differ from their normal counterparts in that each thread that accesses one (via its get or set method) has its ow…
import java.util.HashMap;import java.util.Map;import java.util.Random; /** * Created by chengtao on 17/12/3. * 继5 之后,ThreadLocal就是系统为我们提供的那个map */public class Thread0601_ThreadLocal { private static int data = 0; private static ThreadLocal<Integer>…