RE: [Rcosjava-general] Threading in the applet
Status: Beta
Brought to you by:
newmana
From: Peggy N. <pe...@ip...> - 2001-10-10 23:23:15
|
Hi Andrew thanks. just a couple of questions.... > It goes init(), start(), run(), and stop(). init() does the basic > initialisation. start() calls startThread() (from > setupAnimatorLayouts()). umm, isn't startThread() called from init()? Not that I think it makes a lot of difference, by the looks of it both init() and start() are called again when the page/applet is "refreshed". > If startThread() is not called by start() > then the running variable is always false. So when it gets to run() > the thread waits and is never notified. In what cases would this happen? Possibly stupid question: Are the methods isRunning() and startThread() in the applet accessible (or indeed accessed) from other classes? thanks, Peggy When startThread() is called > by the ProgramManager (from another thread) then it's notified and > keeps running. So if you comment out that call, go to "Program > Manager" and hit "Run" and it will work! > > It was also done for minimize/maximize/entering/leaving/reloading > pages. This was done for largely historic reasons. When RCOS.java > was a 1.1 applet sitting in IE 3/4 and Netscape 3/4 the > init/start/stop/destroy calls were called at different times for > different browser versions. > > If you want information about it check out: > http://support.microsoft.com/support/kb/articles/Q227/2/10.ASP > http://developer.netscape.com/support/faqs/champions/java.html > > In the end, you're probably wondering why I did it this way. Me too. > I don't think this is the best way but I hate threads and it does work > okay but it needs improvement (see below). > > >Q. This 'running' variable - deemed volatile - I understand this to > >mean that it might be changed from an external source ie another > >thread. To compliment my other questions - when does 'running' become > >false, aside from its initialisation? > > > > This is just following Sun's documentation about "Why Thread.stop, > Thread.suspend and Runtime.runFinalizersOnExit is deprecated". > > http://java.sun.com/products/jdk/1.2/docs/guide/misc/threadPrimitiveDe > precation.html > > It's to "ensure prompt communication of the stop-request, the > variable must be volatile (or access to the variable must be > synchronized)." The startThread() method is synchronized but > the isRunning() is not. > > In previous version there was this method: > > public synchronized void stepThread() > { > running = false; > notify(); > } > > This was part of the implementation to step through an instruction at > a time. The bug for this is here: > > http://sourceforge.net/tracker/index.php?func=detail&aid=452014&group_ > id=5762&atid=105762 > > > > >Also, I see that the kernelThread loops around for its existence, > >calling performInstructionExecutionCycle(). Why does the thread then > >sleep? > > > > This is just to allow other threads to run. The animator thread gets > pretty starved when the sleep is removed. > > > __________________________________________________________________ > Your favorite stores, helpful shopping tools and great gift ideas. > Experience the convenience of buying online with Shop@Netscape! > http://shopnow.netscape.com/ > > Get your own FREE, personal Netscape Mail account today at > http://webmail.netscape.com/ > > > _______________________________________________ > Rcosjava-general mailing list > Rco...@li... > https://lists.sourceforge.net/lists/listinfo/rcosjava-general |