JMRI: Threading
The initial threading model for JMRI is quite simple: Everything interesting happens in the GUI thread. For example, once a 'message', e.g. a LocoNet packet, is accumulated in a separate thread, the message is processed in the GUI thread via:
// message is complete, dispatch it !!
{
final LocoNetMessage thisMsg = msg;
final LnTrafficController thisTC = this;
// return a notification via the queue to ensure end
Runnable r = new Runnable() {
LocoNetMessage msgForLater = thisMsg;
LnTrafficController myTC = thisTC;
public void run() {
log.debug("Delayed notify starts");
myTC.notify(msgForLater);
}
};
javax.swing.SwingUtilities.invokeLater(r);
}
This can't work forever, however, so we're working on a new
threading model.
See the working Wiki page for more info.