@@ -0,0 +1,1563 @@
+package com.njust.test.learn;%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0Aimport java.util.Random;%0A%0A/**%0A * %E7%BA%BF%E7%A8%8B%E8%8C%83%E5%9B%B4%E5%86%85%E5%8F%98%E9%87%8F%E5%85%B1%E4%BA%AB%EF%BC%9A%0A * %E6%8C%87%E7%9A%84%E6%98%AF%E5%90%8C%E4%B8%80%E4%B8%AA%E7%BA%BF%E7%A8%8B%EF%BC%8C%E4%BD%86%E6%B6%89%E5%8F%8A%E5%A4%9A%E4%B8%AA%E6%AD%A5%E9%AA%A4(%E7%BB%8F%E5%B8%B8%E6%98%AF%E4%B8%8D%E5%90%8C%E7%B1%BB%E7%9A%84%E6%96%B9%E6%B3%95)%EF%BC%8C%E5%A6%82%E4%BD%95%E5%85%B1%E4%BA%AB%E6%95%B0%E6%8D%AE%0A * %E5%85%B8%E5%9E%8B%E5%9C%BA%E6%99%AF%E6%98%AFweb%E5%BA%94%E7%94%A8%E8%AF%BB%E5%8F%96session%E4%B8%AD%E7%9A%84%E7%99%BB%E5%BD%95%E4%BF%A1%E6%81%AF(%E5%8F%AF%E8%83%BD%E8%B0%83%E7%94%A8%E5%A4%9A%E4%B8%AA%E6%96%B9%E6%B3%95%EF%BC%8C%E4%BD%86%E6%98%AF%E5%B9%B6%E6%B2%A1%E6%9C%89%E5%B0%86session%E4%BF%A1%E6%81%AF%E4%BD%9C%E4%B8%BA%E5%8F%82%E6%95%B0%E4%BC%A0%E6%9D%A5%E4%BC%A0%E5%8E%BB)%0A * ----------------------------------%0A * %3Cpre%3E%0A * Thread-0 put data:-1404320850%0A * Thread-1 put data:605851871%0A * Thread-0 A read data:-1404320850%0A * Thread-1 A read data:605851871%0A * Thread-0 B read data:-1404320850%0A * Thread-1 B read data:605851871%0A * %3C/pre%3E%0A */%0Apublic class ThreadScopeShareData%0A%7B%0A    //private static int data;%0A    %0A    private static Map%3CThread, Integer%3E dataMap = new HashMap%3C%3E();%0A    %0A    public static void main(String%5B%5D args)%0A    %7B%0A        for (int i = 0; i %3C 2; i++)%0A        %7B%0A            new Thread(() -%3E %7B%0A                int data = new Random().nextInt();%0A                dataMap.put(Thread.currentThread(), data);%0A                System.out.println(Thread.currentThread().getName() + %22 put data:%22 + data);%0A                %0A                new A().get();%0A                new B().get();%0A            %7D).start();%0A        %7D%0A    %7D%0A    %0A    static class A%0A    %7B%0A        public void get()%0A        %7B%0A            Integer data = dataMap.get(Thread.currentThread());%0A            System.out.println(Thread.currentThread().getName() + %22 A read data:%22 + data);%0A        %7D%0A    %7D%0A    %0A    static class B%0A    %7B%0A        public void get()%0A        %7B%0A            Integer data = dataMap.get(Thread.currentThread());%0A            System.out.println(Thread.currentThread().getName() + %22 B read data:%22 + data);%0A        %7D%0A    %7D%0A    %0A%7D%0A%0A%0A

Create ThreadScopeShareData.java