Java Disposable pattern

前端 未结 3 1606

C# supports disposable pattern for deterministic garbage collection using the dispose pattern.

Is there such pattern for java?

Java 7 has autoclosable, whic

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-17 11:50

    The entire purpose of the disposal pattern is to support C#'s unique using (temporaryObject) pattern. Java has had nothing like that pattern before 7.

    All Java objects that had resources supported the disposal pattern via manually closing the object that held resources.

提交回复
热议问题