更新时间:2023-02-09 16:21:45
锁定字符串不是一个好主意,我建议两个选择:
Locking on a string is not a good idea. I suggest two alternatives:
字典< int,object>
作为padLocks类型,并将一个 );
作为值。Dictionary<int,object>
as padLocks' type, and put a new object();
as the value.LockPad类:
class LockPad {
public int Id { get; private set; }
public LockPad(int id) {
this.Id = id;
}
public override string ToString() {
return "lock of " + id.ToString();
}
}
然后锁定该类。