1 28 package org.jruby.internal.runtime; 29 30 import org.jruby.RubyThread; 31 import org.jruby.runtime.Block; 32 import org.jruby.runtime.builtin.IRubyObject; 33 34 37 public class NativeThread { 38 private Thread nativeThread; 39 public RubyThread rubyThread; 40 41 public NativeThread(RubyThread rubyThread, IRubyObject[] args, Block block) { 42 this.rubyThread = rubyThread; 43 44 nativeThread = new RubyNativeThread(rubyThread, args, block); 45 } 46 47 public NativeThread(RubyThread rubyThread, Thread nativeThread) { 48 this.rubyThread = rubyThread; 49 this.nativeThread = nativeThread; 50 } 51 52 public void start() { 53 nativeThread.start(); 54 } 55 56 public void interrupt() { 57 nativeThread.interrupt(); 58 } 59 60 public boolean isAlive() { 61 return nativeThread.isAlive(); 62 } 63 64 public void join() throws InterruptedException { 65 nativeThread.join(); 66 } 67 68 public int getPriority() { 69 return nativeThread.getPriority(); 70 } 71 72 public void setPriority(int priority) { 73 nativeThread.setPriority(priority); 74 } 75 76 public boolean isCurrent() { 77 return Thread.currentThread() == nativeThread; 78 } 79 80 public boolean isInterrupted() { 81 return nativeThread.isInterrupted(); 82 } 83 } 84 | Popular Tags |