On Wed, Nov 19, 2008 at 9:54 AM, Aidan Skinner <[EMAIL PROTECTED]> wrote:
> On Wed, Nov 19, 2008 at 2:48 PM, Rajith Attapattu <[EMAIL PROTECTED]> > wrote: > > > Some of our classes directly extends java.lang.Thread. So I believe the > > above strategy will be a bit difficult. > > [..] > > >> Do you have a patch that you used for your experiments that would show > the > >> scope of the changes required? > >> > > Hoping to attach one today for discussion. > > What strategy did you adopt? It would probably be possible to change > the things that extend Thread to a composite that accept thread, or > implement Runnable. > I haven't really decided on a strategy yet and open to suggestions. Your suggestion also is similar to Gordon which I think is very good. However looking at the code in IOSender/Receiver as well as the Dispatcher I see they extends the Thread class directly. So I was thinking about doing something with minimum change to existing code. How about the following idea. Below is a rough sketch. IoSender extends org.apache.qpid.Thread - which is a wrapper class with the same methods as java.lang.Thread. And then define org.apache.qpid.Thread as, public class Thread { private java.lang.Thread delegate; private static Class delegateClass; static{ String delegateClassName = System.getProperty("qpid.threadclass", "java.lang.Thread"); try{ delegateClass = Class.forName(delegateClassName); }catch(Exception e){ ......... } } public Thread() throws Exception { delegate = (java.lang.Thread)delegateClass.newInstance(); } public Thread(String name) throws Exception { Constructor constructor = delegateClass.getConstructor(new Class[]{String.class}); delegate = (java.lang.Thread)constructor.newInstance(new Object[]{name}); } public void start() { delegate.start(); } public void join() throws InterruptedException { delegate.join(); } } We could also delegate the creation of the Threads to a factory class like Gordon suggested which could also hide setting priorities etc for the Realtime threads. > Having something that runs on RT Java is definately interesting. > > - Aidan > -- > Apache Qpid - World Domination through Advanced Message Queueing > http://cwiki.apache.org/qpid > "Nine-tenths of wisdom consists in being wise in time." - Theodore > Roosevelt > -- Regards, Rajith Attapattu Red Hat http://rajith.2rlabs.com/