// thread safeint add(int a, int b) { return a + b;}// not thread safeint add(int a, int b) { static int accumulator; accumulator = a; accumulator += b; return accumulator;}
Unit Tests and Test-Driven Development
Quote:Original post by SiCrane// thread safeint add(int a, int b) { return a + b;}
There's no memory shared there.
Now try writing an entire program this way. It's not really possible in traditional languages built around the shared memory concurrency model, sadly.
Quote:Original post by SiCraneQuote:Original post by truthsayer
There's no memory shared there.
Exactly my point.
So you're talking about a completely uninteresting and trivial case. Congratulations must be in order.
Quote:Original post by truthsayerQuote:Original post by SiCrane// thread safeint add(int a, int b) { return a + b;}
There's no memory shared there.
Now try writing an entire program this way. It's not really possible in traditional languages built around the shared memory concurrency model, sadly.
lol, get a clue.
Quote:Original post by silvermace
lol, get a clue.
You must be that scholar I was looking for.
Care to explain yourself, or are you afraid your ignorance will shine through?
Quote:Original post by truthsayerThat is exactly my objection to the examples in the articles - they introduce shared memory for no reason, as far as I can tell. Perhaps it's a java thing (as I'm not familiar with all the details of java), but in C++ you could use exactly the same design with exactly the same variables but make it completely thread safe by passing around references to local objects instead of using global ones.
[...]There's no memory shared there.[...]
Doh. Before the thread becomes completely derailed...
A selection of TDD articles over at Games from Within
A selection of TDD articles over at Games from Within
Quote:Original post by truthsayerQuote:Original post by silvermace
lol, get a clue.
You must be that scholar I was looking for.
Care to explain yourself, or are you afraid your ignorance will shine through?
Oh man, talk about unfriendliness. SiCrane is one of the more knowledgeable people I know on this forum and I know for a fact that he has no intentions but to help others. Dude, you seriously need to chill out.
Quote:Original post by AshkanQuote:Original post by truthsayerQuote:Original post by silvermace
lol, get a clue.
You must be that scholar I was looking for.
Care to explain yourself, or are you afraid your ignorance will shine through?
Oh man, talk about unfriendliness. SiCrane is one of the more knowledgeable people I know on this forum and I know for a fact that he has no intentions but to help others. Dude, you seriously need to chill out.
Nah, not anymore he doesn't... cus he's banned! Wee!
As far as the object mentor articles go:
Thread safety was not a primary concern when writing them, as threading was not not on the docket as far as concerns go for implementation of the problem they are approaching.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement