[
https://issues.apache.org/jira/browse/HBASE-4613?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13131916#comment-13131916
]
nkeywal commented on HBASE-4613:
--------------------------------
The two implementations should be functionally equivalent, except if the issue
comes from join vs. sleep. The code contained previously a join(), without
timeout parameter, and has been replaced by a sleep.
But t.join(60 * 1000) finishes when t is dead or after 60*1000 ms. So it's
better (if it works :-) than 60 sleeps of 1s each because in average we will
sleep 0.5 seconds after t's death. If you think the "timeouted join" is fine as
well, I will publish the patch.
> hbase.util.Threads#threadDumpingIsAlive sleeps 1 second, slowing down the
> shutdown by 0.5s
> ------------------------------------------------------------------------------------------
>
> Key: HBASE-4613
> URL: https://issues.apache.org/jira/browse/HBASE-4613
> Project: HBase
> Issue Type: Improvement
> Affects Versions: 0.94.0
> Environment: all
> Reporter: nkeywal
> Assignee: nkeywal
> Priority: Minor
>
> Current implementation is:
> {noformat}
> /**
> * @param t Waits on the passed thread to die dumping a threaddump every
> * minute while its up.
> * @throws InterruptedException
> */
> public static void threadDumpingIsAlive(final Thread t)
> throws InterruptedException {
> if (t == null) {
> return;
> }
> long startTime = System.currentTimeMillis();
> while (t.isAlive()) {
> Thread.sleep(1000);
> if (System.currentTimeMillis() - startTime > 60000) {
> startTime = System.currentTimeMillis();
> ReflectionUtils.printThreadInfo(new PrintWriter(System.out),
> "Automatic Stack Trace every 60 seconds waiting on " +
> t.getName());
> }
> }
> }
> {noformat}
> while this one would make more sense considering the documentation, and save
> around 0,5s when the MiniCluster shutdowns.
> {noformat}
> public static void threadDumpingIsAlive(final Thread t)
> throws InterruptedException {
> if (t == null) {
> return;
> }
> while (t.isAlive()) {
> t.join(60 * 1000);
> if (t.isAlive()) {
> ReflectionUtils.printThreadInfo(new PrintWriter(System.out),
> "Automatic Stack Trace every 60 seconds waiting on " +
> t.getName());
> }
> }
> }
> {noformat}
> However, it was replacing a previous implementation with a join without a
> timeout. So if anyone has a warning here...
> Tests seems to be ok...
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira