首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下列程序的输出结果为( )。 public class Reentrant { public synchronized void a() { b(); System.out.
下列程序的输出结果为( )。 public class Reentrant { public synchronized void a() { b(); System.out.
admin
2010-02-22
25
问题
下列程序的输出结果为( )。 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://kaotiyun.com/show/Minp777K
本试题收录于:
二级Java题库NCRE全国计算机二级分类
0
二级Java
NCRE全国计算机二级
相关试题推荐
在考生文件夹下已有一个菜单文件mymenu.mnx,运行相应的菜单程序时会在当前VFP系统菜单的末尾追加一个“考试”子菜单,如图3-9所示(在菜单设计器环境下,使用“常规选项”命令打开相应对话框,在“位置”中指定“追加”)。在考生文件夹下还有一
(1)编写程序文件prgone.prg,其功能是从“人事管理”数据库的相关表中查询销售部从1985—1989年这5年出生的所有职工的信息,并存到表cyqk.dbf中。查询结果包含编号、姓名、出生日期和部门名称(部门表中的名称)4个字段;按职工的出生日期和编
(1)创建一个名为“学生管理”的项目文件。(2)将考生文件夹下的数据库“班级学生”添加到新建的项目文件中。(3)打开数据库“班级学生”,将考生文件夹下的自由表“教师”添加到数据库“班级学生”中;为“教师”表创建一个索引名和索引表达式均为“教师编号”的主
在考生文件夹下,打开资源数据库frdb,完成如下简单应用:(1)使用表单向导选择资源表frt生成一个名为fredit的表单。要求选择frt表中所有字段,样式为阴影式;按钮类型为图片按钮;排序字段选择户主编号(升序);表单标题为“资源数据输入维护”。
在考生文件夹下,打开testdb数据库,完成如下操作:(1)为表sell建立一个主索引,索引名为PK,索引表达式为:部门号+年度+月份。(2)将自由表datatest、model、tabc和pass添加到当前打开的数据库中。(3)在当前数据库中创建
设有两个数据库表,父表和子表之间是一对多的联系,为控制父表和子表中数据的一致性,可以设置“参照完整性规则”,要求()。
已知二叉树后序遍历序列是CDABE,中序遍历序列是CADEB,它的前序遍历序列是()。
假设在表单设计器环境下,表单中有一个复选框且已经被选定为当前对象。现在从属性窗口中选择Value属性,然后在设置框中输入T。请问以上操作后,复选框Value属性值的数据类型为()。
设有一个栈与一个队列的初始状态均为空。现有一个序列A,B,C,D,E,F,G,H。先分别将序列中的前4个元素依次入栈,后4个元素依次入队;然后分别将栈中的元紊依次退栈,再将队列中的元素依次退队。最后得到的序列为
比较线程和进程,下列说法有误的是
随机试题
小学一至二年级认识常用汉字1600个左右,其中800个左右会写。这项要求属于教育目的层级中的()
重置成本估算的方法很多,对于二手汽车的评估,一般采用的方法是_______。
关于外阴鳞状上皮内瘤样变下列哪项是不正确的
输卵管由内向外依次为
A、丙磺舒B、阿司匹林C、秋水仙碱D、别嘌醇E、塞来昔布抗氧化,减少再灌注期氧自由基的产生
分布于面颊部的经脉是
下级人民法院在接到最高人民法院执行死刑的命令后,应于7日内执行。但有下列哪些情形,应当停止执行?
建设工程项目实行总承包的,由( )汇总各分包单位形成的工程档案。
依次填入下列各句括号内的词语,与句意最贴切的一组是()。①爱国主义是一种严肃的爱,看似缥渺,却真实地()着我们的喜怒哀乐。②企业的管理层要不断地()德才兼备的年轻人,培养其中的
在Linux操作系统中,修改文件的属主的命令是______。A.chownB.chmodC.changD.Chgrp
最新回复
(
0
)