R
Richard Maher
Hi,
I have an Applet that instantiates an object that in turn instantiates
another which run()s a Thread that trundles away. Now, if it all goes
pear-shaped in the thread, I want to be able to asynchronously call back
into the applet object and tell it to "do something".
A quick look around leads me to believe that I should create a callback
interface and have the Applet implement it. Then have the Applet pass itself
to the threading-object's constructor and, if something goes wrong, the
thread can cast the applet to the interface and invoke the "callback"
method. Will it work? (I'm off to give it a go, but in case it doesn't (or
if someone knows a "better" way) I'm happy to hear alternatives!)
If I'm forced to go to Plan B and shift the "do something" down-stream, can
someone please answer the following Synchronize question for me? Is the
synchronization behaviour of a "synchronized" method functionally equivalent
to a non-synchronized method that wraps everything in a "synchronized (this)
{}" block?
IOW, will a synchronized block on an object
play-nicely/synchronize-correctly/block with any synchronized methods that
object may contain?
Cheers Richard Maher
I have an Applet that instantiates an object that in turn instantiates
another which run()s a Thread that trundles away. Now, if it all goes
pear-shaped in the thread, I want to be able to asynchronously call back
into the applet object and tell it to "do something".
A quick look around leads me to believe that I should create a callback
interface and have the Applet implement it. Then have the Applet pass itself
to the threading-object's constructor and, if something goes wrong, the
thread can cast the applet to the interface and invoke the "callback"
method. Will it work? (I'm off to give it a go, but in case it doesn't (or
if someone knows a "better" way) I'm happy to hear alternatives!)
If I'm forced to go to Plan B and shift the "do something" down-stream, can
someone please answer the following Synchronize question for me? Is the
synchronization behaviour of a "synchronized" method functionally equivalent
to a non-synchronized method that wraps everything in a "synchronized (this)
{}" block?
IOW, will a synchronized block on an object
play-nicely/synchronize-correctly/block with any synchronized methods that
object may contain?
Cheers Richard Maher