Java同步静态方法:锁定对象或类 [英] Java synchronized static methods: lock on object or class

查看:234
本文介绍了Java同步静态方法:锁定对象或类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Java教程说:同一对象上的同步方法的两个调用不可能交错。

The Java Tutorials say: "it is not possible for two invocations of synchronized methods on the same object to interleave."

这对于静态方法意味着什么?由于静态方法没有关联对象,所以将在类上使用synchronized关键字锁定,而不是对象?

What does this mean for a static method? Since a static method has no associated object, will the synchronized keyword lock on the class, instead of the object?

推荐答案


由于静态方法没有相关联的对象,将同步关键字锁定在类上,而不是对象?

是的。 :)

这篇关于Java同步静态方法:锁定对象或类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆