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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
Paulex Yang
China Software Development Lab
IBM



---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to