覆盖同步方法 [英] Overriding a synchronized method

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

问题描述

当超类中的方法被同步但您在子类中重写该方法而不同步时会发生什么?

What happens when a method in super class is synchronized, but you override the method in a subclass and don't synchronize it ?

推荐答案

如果超类中的方法已同步,但是您在子类中覆盖了该方法并且不对其进行同步,则该方法不再有效如果在子类上调用,则同步..

If a method in super class is synchronized, but you override the method in a subclass and don't synchronize it, then the method is no longer synchronized if called on the subclass.

这篇关于覆盖同步方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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