Welcome to DU! The truly grassroots left-of-center political community where regular people, not algorithms, drive the discussions and set the standards. Join the community: Create a free account Support DU (and get rid of ads!): Become a Star Member Latest Breaking News Editorials & Other Articles General Discussion The DU Lounge All Forums Issue Forums Culture Forums Alliance Forums Region Forums Support Forums Help & Search

Recursion

(56,582 posts)
7. This is the importance of the static keyword
Mon Jun 17, 2013, 10:57 AM
Jun 2013

That's the main advantage of Java and C# from a developer's perspective: the VM forces declaration of static members and methods, so that you can see exactly where you need to worry about concurrency.

If you're sure that there can be no two concurrent calls of any static methods (and anything that accesses a static variable is a static method), then you're fine. I'd actively prove it to myself, though.

In terms of why you care, the normal case for bugs is that a method stores some kind of recordkeeping data in a static variable. User A and user B try to write and read that at the same time, and the result is inconsistent. Inconsistency is a bug, and will eventually make something explode.

Recommendations

0 members have recommended this reply (displayed in chronological order):

Latest Discussions»Retired Forums»Website, DB, & Software Developers»Do I need to worry about ...»Reply #7