首页 > 编程 > Java > 正文

java中synchronized

2019-11-06 08:13:47
字体:
来源:转载
供稿:网友

java中synchronized

锁类的对象

public class Test { // 锁类的对象 public synchronized void methodAAA() {} public void methodBBB() { // 锁类的对象 synchronized (Test.this) {} }}

锁类的方法

public class Test { // 锁类的方法 public synchronized static void methodAAA() { } public static void methodBBB() { // 锁类的方法 synchronized (Test.class) {} }}
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表