harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nikolay Kuznetsov (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-2219) [drlvm][thread] fix Thread.start() waiting to prevent losing interruption
Date Mon, 27 Nov 2006 16:09:22 GMT
    [ http://issues.apache.org/jira/browse/HARMONY-2219?page=comments#action_12453633 ] 
Nikolay Kuznetsov commented on HARMONY-2219:

Salikh, here is my answer to your question from 1789:
> By the way, why we have a waiting loop in Thread.start() at all? Spec does not mandate
it. -- I think I would file a separate JIRA to remove this loop. 

The spec for Thread.start() method says that:
"!!!!The result is that two threads are running concurrently!!!!!: 
the current thread (which returns from the call to the start method) and the other thread
(which executes its run method)."

It seems to me that this means that after return from the start method both threads should
be alive and running, thus synchronization required to wait until child thread run method
was called. The right method to implement this in _java_(synchronization on native side is
also possible) is to put lock.wait() method into while loop on isAlive condition, to avoid
spurious wake-ups and provide expected behavior in any case.

Also, interrupting waiting on start methos thread may cause InterruptedException which is
not expected from the start method, but just ignoring it is also incorrect, because it may
turn into lost interruption. Thus forwarding interrupted status seems to be easiest and correct
 solution for java style start method synchronization.

Thank you.

> [drlvm][thread] fix Thread.start() waiting to prevent losing interruption
> -------------------------------------------------------------------------
>                 Key: HARMONY-2219
>                 URL: http://issues.apache.org/jira/browse/HARMONY-2219
>             Project: Harmony
>          Issue Type: Sub-task
>            Reporter: Salikh Zakirov
>         Attachments: fix-thread-start.patch
> This is a splitted out part of H-1789.patch from HARMONY-1789, originally posted by Nikolay
> fix-thread-start.patch fixes Thread.start() to remember interrupted status if interruptions
occur while it waits for the other thread to start,
> and restore interrupted status before returning.

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


View raw message