Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #37546
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Java 9 issues |
| Date | 2017-10-03 17:36 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <or0vtk$bcn$1@dont-email.me> (permalink) |
| References | <3932fb50-27ec-475c-9e74-45387ba59ac1@googlegroups.com> <fa039415-999b-4a40-9943-422a3ee2495b@googlegroups.com> |
On 10/3/2017 4:34 PM, Eric Douglas wrote:
> On Tuesday, October 3, 2017 at 11:12:18 AM UTC-4, Eric Douglas wrote:
>> Then there's the next trivial issue of all the now deprecated methods I'm referencing.
>> [...]
>> Object.finalize()
> *** this is the tricky one ***
>
> So, what to do with finalize()?? Oracle's comment block on this one simply says it's deprecated, as in the don't know how to properly execute it and just want to do away with it. In this case I have a file watcher class, using java.nio.file.WatchService in a daemon thread, and want to close it properly..
It seems you may have been abusing finalize() as a destructor. That
is and always has been bad practice. Quoth Bloch in "Effective Java:"
Item 6: Avoid finalizers
[...] C++ programmers are cautioned not to think of
finalizers as the analog of C++ destructors. [...]
So what should you do instead of writing a finalizer
for a class whose objects encapsulate resources that
require termination, such as files or threads? Just
provide an explicit termination method, and require
clients of the class to invoke this method on each
instance when it is no longer needed. [...]
Don't try to resuscitate bad practice; reform it.
--
esosman@comcast-dot-net.invalid
Twelve hundred five days to go.
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Java 9 issues Eric Douglas <e.d.programmer@gmail.com> - 2017-10-03 08:12 -0700
Re: Java 9 issues Arne Vajhøj <arne@vajhoej.dk> - 2017-10-03 11:33 -0400
Re: Java 9 issues Patrick Roemer <sangamon@netcologne.de> - 2017-10-03 17:43 +0200
Re: Java 9 issues Arne Vajhøj <arne@vajhoej.dk> - 2017-10-03 12:07 -0400
Re: Java 9 issues Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2017-10-03 11:20 -0500
Re: Java 9 issues Eric Douglas <e.d.programmer@gmail.com> - 2017-10-03 10:19 -0700
Re: Java 9 issues Arne Vajhøj <arne@vajhoej.dk> - 2017-10-03 14:10 -0400
Re: Java 9 issues Patrick Roemer <sangamon@netcologne.de> - 2017-10-03 20:20 +0200
Re: Java 9 issues Arne Vajhøj <arne@vajhoej.dk> - 2017-10-03 15:37 -0400
Re: Java 9 issues Eric Douglas <e.d.programmer@gmail.com> - 2017-10-03 12:52 -0700
Re: Java 9 issues Patrick Roemer <sangamon@netcologne.de> - 2017-10-03 22:27 +0200
Re: Java 9 issues Eric Douglas <e.d.programmer@gmail.com> - 2017-10-03 13:38 -0700
Re: Java 9 issues Patrick Roemer <sangamon@netcologne.de> - 2017-10-03 22:55 +0200
Re: Java 9 issues Arne Vajhøj <arne@vajhoej.dk> - 2017-10-03 19:45 -0400
Re: Java 9 issues Eric Douglas <e.d.programmer@gmail.com> - 2017-10-04 05:18 -0700
Re: Java 9 issues Arne Vajhøj <arne@vajhoej.dk> - 2017-10-04 20:04 -0400
Re: Java 9 issues Eric Douglas <e.d.programmer@gmail.com> - 2017-10-05 06:10 -0700
Re: Java 9 issues Martin Gregorie <martin@address-in-sig.invalid> - 2017-10-05 11:06 +0000
Re: Java 9 issues Eric Douglas <e.d.programmer@gmail.com> - 2017-10-05 06:09 -0700
Re: Java 9 issues Martin Gregorie <martin@address-in-sig.invalid> - 2017-10-05 18:23 +0000
Re: Java 9 issues Eric Douglas <e.d.programmer@gmail.com> - 2017-10-03 12:03 -0700
Re: Java 9 issues Eric Douglas <e.d.programmer@gmail.com> - 2017-10-03 13:34 -0700
Re: Java 9 issues Eric Douglas <e.d.programmer@gmail.com> - 2017-10-03 13:49 -0700
Re: Java 9 issues Arne Vajhøj <arne@vajhoej.dk> - 2017-10-03 19:39 -0400
Re: Java 9 issues Eric Douglas <e.d.programmer@gmail.com> - 2017-10-03 14:01 -0700
Re: Java 9 issues Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-10-03 17:36 -0400
Re: Java 9 issues Eric Douglas <e.d.programmer@gmail.com> - 2017-10-04 07:51 -0700
Re: Java 9 issues Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-10-04 11:20 -0400
Re: Java 9 issues v_borchert@despammed.com (Volker Borchert) - 2017-10-04 20:14 +0000
Re: Java 9 issues Arne Vajhøj <arne@vajhoej.dk> - 2017-10-03 19:23 -0400
csiph-web