- class Ticket implements Runnable
- {
- private int tick = 1000;
- Object obj = new Object();
- public void run()
- {
- while(true)
- {
- synchronized(obj)
- {
- if(tick>0)
- {
- try{Thread.sleep(10);}catch(Exception e){}
- System.out.println(Thread.currentThread().getName()+"....sale : "+ tick--);
- }
- }
- }
- }
- }
复制代码
Thread.sleep(10) 出现异常为什么不能用throws抛出
接口的方法为何不能抛异常 |