public class ThreadInterruptedException extends EnvironmentFailureException
java.lang.InterruptedException(a thread interrupt) or
java.nio.channels.ClosedChannelException(which also results from a thread interrupt) occurs in any JE method. This occurs when the application, or perhaps a library or container that the application is using, calls
Thread.interrupt is not recommended for an active JE
thread if the goal is to stop the thread or do thread coordination. If you
interrupt a thread that is executing a JE operation, the state of the
environment will be undefined. That's because JE might have been in the
middle of I/O activity when the operation was aborted midstream, and it
becomes very difficult to detect and handle all possible outcomes.
When JE detects the interrupt, it will mark the environment invalid and
will throw a
ThreadInterruptedException. This tells you that you
must close the environment and re-open it before using it again. This is
necessary, because if JE didn't throw
is very likely that you would get some other exception that is less
meaningful, or simply see corrupted data.
Instead, applications should use other mechanisms like
wait to coordinate threads. For example, use a
keepRunning variable of some kind in each thread. Check this
variable in your threads, and return from the thread when it is false. Set
it to false when you want to stop the thread. If this thread is waiting to
be woken up to do another unit of work, use
Object.notify to wake it
up. This is the recommended technique.
However, if the use of
Thread.interrupt is unavoidable, be sure
to use it only when shutting down the environment. In this situation,
ThreadInterruptedException should be expected. Note that
by shutting down the environment abnormally, recovery time will be longer
when the environment is subsequently opened, because a final checkpoint was
Environment handles are invalidated as a result of this
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
Copyright (c) 2002, 2015 Oracle and/or its affiliates. All rights reserved.