首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下列程序的输出结果为( )。 public class Reentrant { public synchronized void a() { b(); System.out.
下列程序的输出结果为( )。 public class Reentrant { public synchronized void a() { b(); System.out.
admin
2010-02-22
29
问题
下列程序的输出结果为( )。 public class Reentrant { public synchronized void a() { b(); System.out.println("here I am, in a()"); } public synchronized void b() { System.out.println("here I am, in b()"); } public static void main(String args[ ]) { Reentrant r=new Reentrant(); r.a(); } }
选项
A、here I am, in a()/here I am, in b()
B、hereI am, in b()/here I am, in a()
C、here I am, in a()
D、here I am, in b()
答案
2
解析
此题程序中类Reentrant定义了两个带有synchronized的方法,分别是a()和b()。在Reentrant类的main()方法中,Reentrant类的实例r调用了方法a(),在a()中调用b()。a()的执行过程中,线程的控制将请求并获得r的锁,并开始执行a()方法。由b()的定义可知,线程获得r的对象锁才能运行该方法,而此时r的锁已经由该线程获得,根据Java对象锁的可重入性,该线程将再次获得r的锁,并开始运行方法b()。
转载请注明原文地址:https://jikaoti.com/ti/1jb0FFFM
本试题收录于:
二级Java题库NCRE全国计算机二级分类
0
二级Java
NCRE全国计算机二级
相关试题推荐
设计一个文件名和表单名均为rate的表单,表单的标题为“外汇汇率查询”,表单界面如图3-2222所示,表单中有两个下拉列表框(CombO1和CombO2),这两个下拉列表框的数据源类型(RowSourceType属性)均为字段,且数据源(RowSource
在考生文件夹下完成下列操作:(1)新建“菜单”数据库,将考生文件夹下的所有自由表添加到该数据库中。(2)新建一个项目“菜单管理”,将“菜单”数据库添加进该项目。(3)为“厨师”表创建一个主索引,索引名为PK,索引表达式为“编号
(1)创建一个名为“订单管理”的数据库,并将已有的employee、orders和customer三个表添加到该数据库中。(2)为orders表建立一个普通索引,索引名为nf,索引表达式为“year(签订日期)”。(3)为employee表建立主索引,
在考生文件夹下创建一个顶层表单myform.scx(表单的标题为“考试”),然后创建并在表单中添加菜单(菜单的名称为mymenu.mnx,菜单程序的名称为mymenu.mpr)。效果如图3-7所示。①菜单命令“计算”和“退出”的功能都通过执行过程完成。
假设temp.dbf数据表中有两个字段“歌手号”和“最后得分”,下面程序段的功能是:将temp.dbf中歌手的“最后得分”填入“歌手”表对应歌手的“最后得分”字段中(假设己增加了该字段),在下划线处应该填写的SQL语句是()。USE歌手
检查软件产品是否符合需求定义的过程称为()。
在VisualFoxPro中,对字段设置有效性规则,下面描述正确的是()。
在创建数据库表时,为某个字段定义了有效性规则,这属于数据完整性中的()。
一些重要的程序语言(如C语言和Pascal语言)允许过程的递归调用。而实现递归调用中的存储分配通常用
下列关于线程和进程的说法正确的是()。
随机试题
碳酸盐岩油气藏中形成具有工业价值的产层要具备什么条件?
例如在U/C矩阵中,第2行表示销售管理功能,第2列表示订货数据类,则在其交叉点上的U表示销售管理功能()
繁荣我国社会主义文化的惟一途径是弘扬优秀的传统文化。()
决策遵循的是______原则,而不是______原则。
关于卵巢分泌的激素,错误的是
关于人员密度的说法错误的是()。
权益乘数的高低取决于企业的资本结构:资产负债率越高,权益乘数越高,财务风险越大。()
企业盘盈的固定资产应当通过“待处理财产损溢”科目核算,将其净收益记入“营业外收入”科目中。()
教育目的是一切教育工作的_________和归属。
Onwhichdayoftheweekaretheyhavingtheconversation?
最新回复
(
0
)