package com.gxx.threads.study.test4; /** * 测试类-共享变量,线程不安全 * @author Gxx */ public class TestNotSafe { /** * main方法 * @param args */ public static void main(String[] args) { MyThread thread = new MyThread(); Thread thead1 = new Thread(thread); Thread thead2 = new Thread(thread); Thread thead3 = new Thread(thread); Thread thead4 = new Thread(thread); Thread thead5 = new Thread(thread); Thread thead6 = new Thread(thread); Thread thead7 = new Thread(thread); Thread thead8 = new Thread(thread); Thread thead9 = new Thread(thread); Thread thead10 = new Thread(thread); thead1.start(); thead2.start(); thead3.start(); thead4.start(); thead5.start(); thead6.start(); thead7.start(); thead8.start(); thead9.start(); thead10.start(); } }