How should I stop the forked VM?

Behrooz Nobakht nobeh5 at gmail.com
Tue Jan 13 08:20:17 UTC 2015


Hi Aleksey,

Thanks for your reply. Hope this helps:
https://github.com/nobeh/jmh-forked-main-threads

Cheers,
Behrooz
​

On Mon, Jan 12, 2015 at 10:57 AM, Aleksey Shipilev <
aleksey.shipilev at oracle.com> wrote:

> Hi,
>
> On 01/12/2015 12:50 PM, Behrooz Nobakht wrote:
> > So I started to use jstack -l on the ForkedMain for my benchmark. Here
> are
> > some observations:
> >
> >    - There are threads all with TIMED_WAITING state.
> >    - I do not have explicit control over the above threads.
> >    - If I do a System.exit(0) somewhere inside ForkedMain, then JMH is
> >    annoyed and will not continue.
>
> I smell a bug here, can you produce a minimal scenario?
>
> > Is there a way, I can safely, issue a System.exit() and JMH would
> continue
> > to finalize the benchmark?
>
> Calling System.exit() from the benchmark running in a forked VM should
> produce a benchmark failure, while still properly shutting down the
> forked VM.
>
> There is no way to call a magic method and have a graceful shutdown. You
> have to control the threads. As the minimal option, you have to make the
> threads daemon, so that their existence would not prevent forked VM from
> exiting.
>
> Thanks,
> -Aleksey.
>
>


-- 
-- Behrooz Nobakht


More information about the jmh-dev mailing list