content: package thread.example01.test6;
  
  /**
   * @auther 陈郑游
   * @create 2017/4/3 0003
   * @功能  锁对象的改变问题
   * @问题
   * @说明
   * @URL地址
   * @进度描述
   */
  public class ChangeLock {
  
  	private String lock = "lock";
  	
  	private void method(){
  		synchronized (lock) {
  			try {
  				System.out.println("当前线程 : "  + Thread.currentThread().getName() + "开始");
  				lock = "change lock";
  				Thread.sleep(2000);
  				System.out.println("当前线程 : "  + Thread.currentThread().getName() + "结束");
  			} catch (InterruptedException e) {
  				e.printStackTrace();
  			}
  		}
  	}
  
  
  	//main
  	public static void main(String[] args) {
  	
  		final ChangeLock changeLock = new ChangeLock();
  		Thread t1 = new Thread(new Runnable() {
  			@Override
  			public void run() {
  				changeLock.method();
  			}
  		},"t1");
  
  		Thread t2 = new Thread(new Runnable() {
  			@Override
  			public void run() {
  				changeLock.method();
  			}
  		},"t2");
  		t1.start();
  
  		try {
  			Thread.sleep(3000);
  		} catch (InterruptedException e) {
  			e.printStackTrace();
  		}
  		t2.start();
  	}
  	
  }
  