首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

第五十三道Java小疑点

2012-12-25 
第五十三道Java小问题import java.util.concurrent.TimeUnitclass TestWork {volatile int i 0void f(

第五十三道Java小问题

import java.util.concurrent.TimeUnit;class TestWork {volatile int i = 0;void f() throws InterruptedException {while (i == 0)wait();System.out.println("Waken!");}synchronized void g() {i = 1;notifyAll();}}class Test {public static void main(String[] args) throws Exception {final TestWork work = new TestWork();new Thread() {public void run() {try {work.f();} catch (InterruptedException e) {}}}.start();TimeUnit.SECONDS.sleep(1);new Thread() {public void run() {work.g();}}.start();}}

?

请问以上程序的输出是:

热点排行