package com.camnter.effective.test;

/**
 * Description：Student
 * Created by：CaMnter
 */

public class Student {

    int number = 0;
    String name = "";


    public void setNumber(int n) {
        synchronized (name) {
            this.number = n;
            System.out.println("Thread :" + Thread.currentThread().getId() + "  #    setNumber    " + this.number);
            System.out.println("Thread :" + Thread.currentThread().getId() + "  #    setNumber  sleep  start");
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("Thread :" + Thread.currentThread().getId() + "  #    setNumber  sleep  end");
        }
    }


    public void setNumber2(int n) {
        synchronized (name) {
            this.number = n;
        }
        System.out.println("Thread :" + Thread.currentThread().getId() + "  #    setNumber2    " + this.number);
        System.out.println("Thread :" + Thread.currentThread().getId() + "  #    setNumber2  sleep  start");
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("Thread :" + Thread.currentThread().getId() + "  #    setNumber2  sleep  end");
    }


    public synchronized void setName(String s) {
        synchronized (name) {
            this.name = s;
        }
        System.out.println("Thread :" + Thread.currentThread().getId() + "  #    setName    " + this.name);
        System.out.println("Thread :" + Thread.currentThread().getId() + "  #    setName  sleep  start");
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("Thread :" + Thread.currentThread().getId() + "  #    setName  sleep  end");
    }
}

@@ -849,30 +849,24 @@
 er = n;%0A    
-    %7D%0A
         Syst
@@ -966,32 +966,36 @@
 umber);%0A        
+    
 System.out.print
@@ -1079,38 +1079,46 @@
 tart%22);%0A        
+  
+  
 try %7B%0A
+    
             Thre
@@ -1133,32 +1133,36 @@
 (3000);%0A        
+    
 %7D catch (Interru
@@ -1184,32 +1184,36 @@
 ) %7B%0A            
+ 
+   
 e.printStackTrac
@@ -1217,34 +1217,42 @@
 race();%0A        
-%7D%0A
+    %7D%0A    
         System.o
@@ -1338,24 +1338,34 @@
 eep  end%22);%0A
+        %7D%0A
     %7D%0A%0A%0A    
@@ -1466,30 +1466,24 @@
 me = s;%0A    
-    %7D%0A
         Syst
@@ -1578,32 +1578,36 @@
 .name);%0A        
+    
 System.out.print
@@ -1688,38 +1688,46 @@
 tart%22);%0A        
+  
+  
 try %7B%0A
+    
             Thre
@@ -1742,32 +1742,36 @@
 (3000);%0A        
+    
 %7D catch (Interru
@@ -1793,32 +1793,36 @@
 ) %7B%0A            
+ 
+   
 e.printStackTrac
@@ -1826,34 +1826,42 @@
 race();%0A        
-%7D%0A
+    %7D%0A    
         System.o
@@ -1944,20 +1944,31 @@
 eep  end%22);%0A
+        %7D%0A%0A
     %7D%0A%7D%0A

Update Student