Why ++ operator is not thread safe(blog.decarufel.net)
submitted by decarufe(959) 3 years ago
Here is a quick hint on how to make your software thread safe.
2 comments |category: Tips & Tricks |Views: 515 Tweet
tags: Tips another
Add a live kick counter to your blog >>
You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:
Simply copy and paste this HTML into your blog post.
posted by JonnyRocks(0) 2 years, 11 months ago 0
This article is not well written out. Are you saying your variable is static? then i guess you are right? but if threads are creating instances of these classes then each thread has its own copy. Obviously the poster ran into an issue and made his scenario fit all. Thats like me saying don't walk outside. Everytime you walk outside you get shot. Then you research and come to fin out I was walking in a heavily contested area of Iraq shoouting obscenities.
Reply
posted by zoidbeck(0) 2 years, 7 months ago 0
I think you comment seems to have the same problem. This IS of course about shared instances, static or not. If each thread has its own copy you won't have to bother about thread safety at all. But imo getting this informations about threadsafety of such a fundamental and basic operation like ++ helps you gettin aware about hard to track threadding related bugs. So maybe this trival information is in fact missing but though i find this article quite helpfull.
All tags Your tags
Suggest a new category
dpeterson(1831)
pwhe23(1134)
rcash(540)
vijayst(504)
bsenoff(361)
bnaya(312)
winphonegeek(260)
Matt_TCF(253)
isenthil(250)
Noldorin(235)