执行如下程序,输出结果是(&nbsp &nbsp &nbsp ) c...
发布于 2022-03-03 15:16:06
执行如下程序,输出结果是( )
class Test{ private int data int result = 0 public void m(){ result += 2 data += 2 System.out.println(result + " " + data) } } class ThreadExample extends Thread{ private Test mv public ThreadExample(Test mv){ this.mv = mv } public void run(){ synchronized(mv){ mv.m() } } } class ThreadTest{ public static void main(String args[]){ Test mv = new Test() Thread t1 = new ThreadExample(mv) Thread t2 = new ThreadExample(mv) Thread t3 = new ThreadExample(mv) t1.start() t2.start() t3.start() } }
登录后免费查看答案
关注者
0
被浏览
20