tag:blogger.com,1999:blog-27876765.post9186191130641062779..comments2024-03-20T13:37:39.909+01:00Comments on Day to day stuff: Java thread controlErik van Oostenhttp://www.blogger.com/profile/15976519439979651010noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-27876765.post-83998275039699765762008-09-22T11:19:00.000+02:002008-09-22T11:19:00.000+02:00this article was extremly useful, thanks a lot!ps:...this article was extremly useful, thanks a lot!<BR/><BR/>ps: you misspelled thread in the titleAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-27876765.post-89887919840791312122008-09-09T10:14:00.000+02:002008-09-09T10:14:00.000+02:00Yeah I know about daemon threads. Daemon threads o...Yeah I know about daemon threads. Daemon threads only solve a tiny part of the problem, making them useful in just a few circumstances. As soon as your thread needs to do some data persistence, or something that simply needs to finish, declaring a thread as daemon won't help.Erik van Oostenhttps://www.blogger.com/profile/15976519439979651010noreply@blogger.comtag:blogger.com,1999:blog-27876765.post-43507964546995137562008-09-09T10:06:00.000+02:002008-09-09T10:06:00.000+02:00You can also set a thread to daemon so it will not...You can also set a thread to daemon so it will not prevent the JVM from exiting.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-27876765.post-78218869279574797442008-08-13T10:36:00.000+02:002008-08-13T10:36:00.000+02:00You should never use the synchronized keyword on m...You should never use the synchronized keyword on methods. There are several reasons for not doing this, but the most important one is that you should minimize the amount of time that is spent in the synchronized block. There are many more subtle reasons.<BR/><BR/>It is indeed possible to drop the volatile keyword when you need to synchronize on something else anyway.<BR/><BR/>Conditions are nice but a bit too advanced for this article.Erik van Oostenhttps://www.blogger.com/profile/15976519439979651010noreply@blogger.comtag:blogger.com,1999:blog-27876765.post-7401368948279704742008-08-11T05:03:00.000+02:002008-08-11T05:03:00.000+02:00I put the Thread's termination flag & work...I put the Thread's termination flag & work-queue together, as an object; and synchronize on that.<BR/><BR/>This provides a single point of control for one, or multiple, threads.<BR/><BR/>Synchronization can be easily wrapped up, using 'synchronized' method modifiers..<BR/><BR/>Threads can synchronize & wait on all control conditions, as a group;<BR/><BR/>And control-conditions, can efficiently wake & notify one/or all threads on change.<BR/><BR/>Seems pretty sound, to me.Anonymousnoreply@blogger.com