tag:blogger.com,1999:blog-3058629931336799294.post250961596678412476..comments2024-03-28T14:54:38.388+05:30Comments on Make Code Easy: Java Multithreadingrahulhttp://www.blogger.com/profile/11031765722695855607noreply@blogger.comBlogger1125tag:blogger.com,1999:blog-3058629931336799294.post-18661507985673640632013-02-12T16:08:27.176+05:302013-02-12T16:08:27.176+05:30That's okey. But by doing multithreading, it&#...That's okey. But by doing multithreading, it's mostly not done by only creating several threads. The other important part is using locks (for shared objects), while I always only suggest block locking: synchronized(object){....}. Java has a great built-in mechanism to to multihreading, but using threads and using locks come hand in hand. So if you teach how to create threads, you also need to teach how to create locks. And since the controller should always be aware of the lock, it's not good to use synchronized methods, it's better to always explicitly lock and free an object, also to avoid deadlocks. In the end it's all about maintainable code. Peace.Anonymousnoreply@blogger.com