public synchronized Object co_entry_pause ( int thisCoroutine ) throws java . lang . NoSuchMethodException { if ( ! m_activeIDs . get ( thisCoroutine ) ) throw new java . lang . NoSuchMethodException ( ) ; while ( m_nextCoroutine != thisCoroutine ) { try { wait ( ) ; } catch ( java . lang . InterruptedException e ) { // %TBD% -- Declare? Encapsulate? Ignore? Or // dance widdershins about the instruction cache? } } return m_yield ; }
In the standard coroutine architecture coroutines are identified by their method names and are launched and run up to their first yield by simply resuming them ; its s presumed that this recognizes the not - already - running case and does the right thing . We seem to need a way to achieve that same threadsafe run - up ... eg start the coroutine with a wait .