说明:在Object对象里面有关于对象等待和恢复的方法,程序中要进行暂停和恢复时需要用到这几个方法,使用时要注意的是, 调用等待或者唤醒的代码要放在synchronized代码块中
代码如下:
//暂停 current = new Object(); synchronized (current) { try { current.wait(); } catch (InterruptedException e) { //打印日志 //e.printStackTrace(); } }//唤醒 if(null!=current){ synchronized (current) { current.notifyAll(); } }
太阳系 -http://blog.csdn.net/fellting