@JRubyMethod(name = "stop", meta = true) public static IRubyObject stop(ThreadContext context, IRubyObject receiver) { RubyThread rubyThread = context.getThread(); synchronized (rubyThread) { rubyThread.checkMail(context); try { // attempt to decriticalize all if we're the critical thread receiver.getRuntime().getThreadService().setCritical(false); rubyThread.status.set(Status.SLEEP); rubyThread.wait(); } catch (InterruptedException ie) { rubyThread.checkMail(context); rubyThread.status.set(Status.RUN); } } return receiver.getRuntime().getNil(); }
public void pollThreadEvents(ThreadContext context) { if (mail != null) checkMail(context); }