5,805 reputation
1438
bio website
location Los Angeles, CA
age
visits member for 3 years, 10 months
seen 41 mins ago

I love strange shrimp.

eh, string stream.


1d
awarded  Popular Question
2d
revised Implementation strategies for atomic counter
edited body
2d
revised Implementation strategies for atomic counter
edited body
2d
comment Implementation strategies for atomic counter
@Euphoric: According to OP's comments, OP takes responsibility for making sure the number of calls to Decrement() always match up the initial count (by way of initializing exactly that number of threads/workers/tasks and nothing more). But since it's a small change, I have now edited it into my answer. Thanks for your suggestion.
2d
comment Implementation strategies for atomic counter
My personal choice is actually to wrap all tasks ("threads" in your words) as Task, and use Task.WhenAll(Task[])
2d
answered Implementation strategies for atomic counter
2d
comment Implementation strategies for atomic counter
See: CountdownEvent class (since .NET 4.0), which is probably based on Win32 HANDLE.
2d
comment Implementation strategies for atomic counter
Other advice will depend on: Is the value initialized to a positive value in a thread-safe manner? Aside from decrements, will there be any other changes to the value? Will there be a possibility of overshoot? (i.e. going negative, which may happen if either (1) there are more decrement operations than the initial count, or (2) some decrement operations decrease the value by more than one) What is the purpose of the "frequent polling", given it is a cause for inefficiency? Why isn't an alternative used?
2d
comment Implementation strategies for atomic counter
Why is the counter "frequently polled" ? If you need to trigger an one-off task as soon as the counter goes to zero, you can just check the return value from Interlocked.Decrement(); if it is zero, call a callback function (or delegate).
Jul
29
comment When is a number a magic number?
In other platforms, such as Windows and Android, such property files and constant-value files belong to the collection of "resource files" consumed and generated (updated) by the build system.
Jul
29
comment When is a number a magic number?
I wonder if there is already a tool for generating the Java constants source file given the ".property" file as input. For example, the generated constant file could contain public final class Strings { public static final class Error { public static final class Email { public static final String Address = "error.invalid.email.address"; } } }
Jul
29
comment How to spread awareness for generic programming among team members?
People who refuse to use generics/templates for large-scale software engineering will accidentally and inevitably build a "second language" - an interpreter that runs on Java, that implements whatever "business language" they have in their mind. en.wikipedia.org/wiki/Inner-platform_effect
Jul
29
comment What algorithms would suit image colour summarization?
If one needs to arrive at a foolproof result, one must consider the possibility of using mechanical turk (i.e. human-assisted labeling), either as a completely manual process or as a final verification step. The problem is that what a human "considers" to be the dominant color can be counter-intuitive for an algorithm designer (i.e. intuition is not intuitive.)
Jul
26
comment How to learn new technologies in short period of time?
Also see: T-shaped skillset which is a strategy that HR professionals can recommend to everyone. Try to develop deep knowledge about a few specialty domains, and then some general knowledge about anything else.
Jul
26
comment How to learn new technologies in short period of time?
The trick is to identify a "profitable subset" of the list of technology, and learn that. How one defines the "profitable subset" is subject to debate.
Jul
24
comment Passing data between hundreds of objects in java
@Doval It's because OP places the main concern on architecture (methodology and scalability), whereas the more important concern should have been the details of the operations (queries) needed to be performed by the simulations.
Jul
24
revised Passing data between hundreds of objects in java
deleted 3 characters in body
Jul
24
answered Passing data between hundreds of objects in java
Jul
24
comment Android SDK and Iphone SDK limitations
Similar designs may have been patented, such as this. If you have a question about prior-art, you can ask on Patents StackExchange.
Jul
24
comment Android SDK and Iphone SDK limitations
My comment (regarding the need for legal opinions) is for systems that may serve similar purpose as existing emergency (distress) call systems: Enhanced 9-1-1 system in North America), and whether it may complement, compete or interfere with its capabilities or features.