作者aleelyle (lyle)
看板java
标题Re: [问题] 在物件被注销时自动执行某些事
时间Tue Jun 12 20:24:56 2012
因为java没有destructor
而且不能保证物件何时被release掉
所以不能像c++一样用物件管理资源
JSE 7 以後新增了 try-with-resources Statement
http://www.javacodegeeks.com/2011/07/java-7-try-with-resources-explained.html
可以少写一些东西....
或是用这个
Execute Around Pattern
http://stackoverflow.com/questions/341971
如果你很坚持的话...自己实作reference count
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 59.104.186.35
※ 编辑: aleelyle 来自: 59.104.186.35 (06/12 20:35)
※ 编辑: aleelyle 来自: 59.104.186.35 (06/12 20:36)
1F:推 LaPass:谢谢资讯,我研究看看 06/13 13:58