Scheduling bug in Kaffe - workaround

Gary Howland gary at systemics.com
Fri Apr 18 08:18:45 PDT 1997


> 
> > I've been using wait/notify in conjunction with the Biss library.  When I run 
> > my application using Suns JDK on FreeBSD, it works as expected.  When I run it 
> > using kaffe .83, it doesn't.  Are there any known wait/notify problems?

I've come up with a workaround to the scheduling problem, if anyone is 
interested.  The following piece of code now works correctly.

Gary
-- 
pub  1024/C001D00D 1996/01/22  Gary Howland <gary at systemics.com>
Key fingerprint =  0C FB 60 61 4D 3B 24 7D  1C 89 1D BE 1F EE 09 06 

    /**
     * The Observer callback
     * This method resumes the suspended thread for that window
     */
    public void
    update(Observable o, Object arg)
    {
        synchronized (arg)
        {
            windows.put(arg, arg); 
            arg.notify();
        }
    }
 
    /**
     * Suspend this thread until the window (or whatever) has finished
     * @param o the Observable object that will call our update method
     */
    public void
    waitForClose(Object obj)
    {
        // 
        // Work around kaffe scheduling bug
        //
        Thread me = Thread.currentThread();
        int prio = me.getPriority();
        me.setPriority(prio+5);

        synchronized (obj)
        {
            while (windows.remove(obj) == null)
            {
                try { 
                    obj.wait();
                }
                catch (InterruptedException e) { throw new RuntimeException("Doh!"
); }
            }
        }
        
        // Restore priority after working around kaffe bug
        me.setPriority(prio);
    }





More information about the kaffe mailing list