Пример #1
0
 public synchronized void checkMail(ThreadContext context) {
   ThreadService.Event myEvent = mail;
   mail = null;
   if (myEvent != null) {
     switch (myEvent.type) {
       case RAISE:
         receivedAnException(context, myEvent.exception);
       case KILL:
         throwThreadKill();
     }
   }
 }
Пример #2
0
  @JRubyMethod(name = {"kill", "exit", "terminate"})
  public IRubyObject kill() {
    // need to reexamine this
    RubyThread currentThread = getRuntime().getCurrentContext().getThread();

    // If the killee thread is the same as the killer thread, just die
    if (currentThread == this) throwThreadKill();

    debug(this, "trying to kill");

    currentThread.pollThreadEvents();

    getRuntime()
        .getThreadService()
        .deliverEvent(new ThreadService.Event(currentThread, this, ThreadService.Event.Type.KILL));

    debug(this, "succeeded with kill");

    return this;
  }