1) The following change (on top of H-1789.patch) fixes unit test hang:
@@ -59,7 +59,9 @@ IDATA VMCALL hythread_park(I_64 millis,
return (t->state & TM_THREAD_STATE_INTERRUPTED) ? TM_ERROR_INTERRUPT : TM_ERROR_NONE;
+ t->state |= TM_THREAD_STATE_PARKED;
status = hycond_wait_interruptable(t->condition, t->mutex, millis, nanos);
+ t->state &= ~TM_THREAD_STATE_PARKED;
//status = hysem_wait_interruptable(t->park_event, millis, nanos);
//the status should be restored for j.u.c.LockSupport
2) The patch is fixing the stated problem directly, however, the attached test case is not a reproducer for the problem. That's why it passes even without the patch.
It looks like H-1789.patch has several unrelated changes. I am going now to split it into series of independent changes. I'll include the above fix as well.
Generally, the approach looks correct and makes sleep(), park() and unpark() code easier to understand and reason about.