harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paulex Yang <paulex.y...@gmail.com>
Subject Re: [Fwd: [classlib][NIO|VMI]Interruptible channel implementation - how to interact with Thread?]
Date Fri, 23 Jun 2006 06:48:58 GMT
Archie Cobbs wrote:
> Paulex Yang wrote:
>> Actually I propose the default value of "interrupt action" is null, 
>> which means the VM will do what it suppose to do for the general 
>> cases(wait(), join(), etc) as before, so the interrupt() might looks 
>> like:
>>
>> public void interrupt(){
>>    if(action != null){
>>       action.run();
>>    }
>>    //call native method to do what it supposed to do
>>    interruptImpl();
>> }
>
> If you do that, and the VM uses signals, then interruptImpl() is going 
> to unexpectedly
> wake up your NIO threads with a signal, right?
Archie,

I'm not sure what will the threads look like if it is "waken up" again 
by signal. If the result is unexpected, so for the VM that implements 
thread using signal, maybe the interrupt() can be:

public void interrupt(){
   if(action != null){
      action.run();
   }else{ //call native method to do what it supposed to do
      interruptImpl();
   }
}

Actually for other thread implementation, possibly also nothing more 
necessary to waking up NIO threads except invoke action. So it may be 
also safe for all kernel class Thread to implement interrupt() like 
above. I think the VM/kernel class implementation should have the 
freedom to make the choice. Even more, as you mentioned, the action can 
be set to invoke native codes for general wait()/join() cases, i.e., the 
Thread.wait() might looks like:

public void wait(){
    action = new Runnable(){
       public void run(){
          interruptImpl();
       }
    }
    //blabla
}

So that it's fine for interrupt() to invoke action.run() only.
>
> -Archie
>
> __________________________________________________________________________ 
>
> Archie Cobbs      *        CTO, Awarix        *      
> http://www.awarix.com
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>


-- 
Paulex Yang
China Software Development Lab
IBM



---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Mime
View raw message