java并发
This commit is contained in:
@ -0,0 +1,33 @@
|
||||
package com.heibaiying.lockOptimization;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class Employee {
|
||||
private String name;
|
||||
private int age;
|
||||
private Date birthday;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
public void setAge(int age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
public Date getBirthday() {
|
||||
return birthday;
|
||||
}
|
||||
|
||||
public void setBirthday(Date birthday) {
|
||||
this.birthday = birthday;
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.heibaiying.lockOptimization;
|
||||
|
||||
/**
|
||||
* 锁消除
|
||||
*/
|
||||
public class LockElision {
|
||||
|
||||
private String toJson(Employee employee) {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("name:").append(employee.getName());
|
||||
buffer.append("age:").append(employee.getAge());
|
||||
buffer.append("birthday:").append(employee.getBirthday());
|
||||
return buffer.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user