题目

[问答题]请完成下列Java程序:运行3个线程,每一个线程有自己的标志,用a,b,c表示,每个线程显示一个“Start”信息和一个“End”信息并且间隔地显示2个“Loop”信息(间隔变化为(0.5-2)秒之间的随机延迟)。
程序运行结果如下:(注:由于时间间隔为随机数,所以,运行结果的顺序不惟一)
aStart
bStart
cStart
bLoop
aLoop
bLoop
bEnd
cLoop
aLoop
aEnd
cLoop
cEnd
注意:请勿改动main()主方法和其他已有语句内容,仅在下划线处填入适当的语句。
publicclassex2_2implementsRunnable
staticcharflag2_2=’a’;
publicstaticvoidmain(String[]arg)
ex2_2obj2_2=newex2_2();
Threadthread2_2=newThread(obi2_2);
thread2_2.start();
thread2_2=newThread(obj2_2);
thread22.start();
thread2_2=newThread(obi2_2);
thread2_2.start();
publicvoidrun()
charmyflag2_2;
synchronized(this)
_________________;
System.out.

提示:未搜索到的试题可在搜索页快速提交,您可在会员中心"提交的题"快速查看答案。
答案
查看答案
相关试题
[单项选择题]对关键字和值带来更多操作功能的类是()。
A.Class类
B.Object类
C.Hashtable类
D.Properties类

电器的保险丝只能装在()上。

  • A.零线
  • B.火线
  • C.底线
[填空题]请完善程序(程序文件名:Java_1.java)并进行调试。请在下画线处填入正确内容,然后删除下画线。请勿删除注释行和其他已有的语句内容。
[题目要求]
完成程序并运行,得到的结果如下图所示。

源程序:
importjavax.swing.JOptionPane;
publicclassJava_1
 publicstaticvoidmain(Stringargs[])
  Stringoutput="";
   for(intcount=1;count<=10;(1))
   if(count(2))
    continue;//当count为5时跳过循环中的剩余代码
    output+=count+"":
 
 output+="Usedcontinuetoskipprinting5":
 JOptionPane.showMessageDialog(null,output);
 System.exit(0);
 
[单项选择题]类中限定为()的成员变量和成员方法可以被除了不同包中的非子类访问。
A.private
B.protected
C.public
D.default
[填空题]本程序的功能是:找出所有满足各位数字之和正好是其所有质因子之和的三位数。例如378,其各位数字之和为18,而其质因子2,3,3,3,7之和也是18,所以378是满足条件的数。OptionExplicitPrivateSubCmdFind_Click()DimiAsInteger,pAsString,stAsString,st1AsStringFori=100To999()Ifcsum(i)=zyz(i,st)Thenp=CStr(i)st1=Left(p,1)&"+"&Mid(p,2,1)&"+"&Right(p,1)List1.AddItemi&":"&st1&"="&Left(st,Len(st)-1)EndIfNextiIfList1.ListCount=0ThenList1.AddItem"无满足要求的数!"EndIfEndSubPrivateFunctioncsum(mAsInteger)AsInteger’求各位数字之和DimiAsInteger,pAsStringp=CStr(m)Fori=1ToLen(p)()NextiEndFunctionPrivateFunctionzyz(ByValmAsInteger,stAsString)AsInteger’求所有质因子之和DimiAsIntegeri=2DoIfmModi=0Thenzyz=zyz+ist=st&i&"+"m=miEIse()EndIfLoopUntil()EndFunction
联系我们 会员中心
返回顶部