Avoid Mixing static and non static synchronized method - Java mistake 2 Example
Using a static and non-static synchronized method for protecting shared resources is another Java mistake we are going to discuss in this part of our series “learning from mistakes in Java”. In the last article, we have seen why double and float should not be used for monetary calculation, In this tutorial, we will find out why using static and non-static synchronized methods together for protecting the same shared resource is not advisable. I have seen some times Java programmers mix static synchronized method and instance synchronized method to protect the same shared resource.
تعليقات
إرسال تعليق