Conversion of most of the sample code has gone well, but the threads
have thrown me into a state of confusion
Any clues on how to code the following in JRuby. Google has not been
much help.
e.g. How to use syncronized in the stop method is one of my problems.
public void start() {
thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
public synchronized void stop() {
thread = null;
}
public void run() {
Thread me = Thread.currentThread();
while (thread == me) {
repaint();
try {
thread.sleep(10);
} catch (InterruptedException e) { break; }
}
thread = null;
}
Conversion of most of the sample code has gone well, but the threads
have thrown me into a state of confusion
Any clues on how to code the following in JRuby. Google has not been
much help.
e.g. How to use syncronized in the stop method is one of my problems.
The use of synchronized there is rather odd, since thread = null is
mostly dependent on the thread field being volatile. I wouldn’t worry
about that on the Ruby side…you can use that or some other
value/attribute as a trigger to shut down the thread.
Charlie
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.