-
Notifications
You must be signed in to change notification settings - Fork 53
Description
I already created an issue in SCIFIO project: scifio/scifio#486 But probably it should be here.
I'm using SCIFIO for reading and parsing large TIFF files with help of your TiffParser class.
I've notices that almost any usage of io.scif SCIFIO (current version 0.44) creates a background non-daemon thread, named like
SciJava-6b53e23f-Thread-0@1742
This is a problem: this thread prevents an application to be normally closed.
This thread appears while any attempt to create SCIFIO context, both by
new Context(false)
or
SCIFIO scifio = new SCIFIO(); Context context = scifio.getContext();
operators. The only variant when there is no problem is creating empty context by new Context(true), but such a context is useless: it leads to NullPointerException when passed to TiffParser constructor.
I've found a possible workaround: I can manually close the created context by context.close() call, and the extra thread will be closed. However, it is not a good solution due to at least 2 reasons.
- Contexts are created in invisible manner by a lot of SCIFIO methods, like IO.opener(), IO.save(some_image) etc. If at least one of such contexts will not be closed manually, parasite thread remains.
- I'm using SCIFIO as a maven library A, which is used inside another library B, which is used inside another library C, etc. My end user does not know anything about the fact that a low-level library A uses SCIFIO, when the processed file is TIFF - it is an implementation detail. So, at the high level there is no suitable point where we could close SCIFIO contexts.
Is it possible to resolve this problem? In particular, is it possible to make the service thread "SciJava-..." a daemon thread, not preventing normal usage of this library? Or, maybe, you could add an ability to create working context without creating any threads?
Note that this problem was not so critical in old SCIFIO version 0.11.0. In that version, the call SCIFIO scifio = new SCIFIO() did not create an additional thread, and we could freely use scifio.getContext() But calls like IO.openImgs(...) were problematic also in that version.