concurrency

What are some good resources for learning threaded programming?

With the rise of multicore CPUs on the desktop, multithreading skills will become a valuable asset for programmers. Can you recommend some good resources (books, tutorials, websites, etc.) for a programmer who is looking to learn about threaded programming?...

Document Server: Handling Concurrent Saves

I'm implementing a document server. Currently, if two users open the same document, modify it and save the changes, document's state will be undefined (either the first user's changes are saved permanently, or the second's). This is entirely unsatisfactory. I considered two possibilities to solve this problem. The first is to lock docum...

Analyzing Multithreaded Programs

We have a codebase that is several years old, and all the original developers are long gone. It uses many, many threads, but with no apparent design or common architectural principles. Every developer had his own style of multithreaded programming, so some threads communicate with one another using queues, some lock data with mutexes, ...

Is Project Darkstar Realistic?

Project Darkstar was the topic of the monthly JavaSIG meeting down at the Google offices in NYC last night. For those that don't know (probably everyone), Project Darkstar is a framework for massively multiplayer online games that attempts to take care of all of the "hard stuff." The basic idea is that you write your game server logic ...

Erlang-style Concurrency for Other Languages

What libraries exist for other programming languages to provide an Erlang-style concurrency model (processes, mailboxes, pattern-matching receive, etc.)? Note: I am specifically interested in things that are intended to be similar to Erlang, not just any threading or queueing library. ...

Best method to get objects from a BlockingQueue in a concurrent program?

What is the best method to get objects out of a BlockingQueue, in a concurrent program, without hitting a race condition? I'm currently doing the following and I'm not convinced it is the best method: BlockingQueue<Violation> vQueue; /* in the constructor I pass in a BlockingQueue object full of violations that need to be processed -...

Best architecture for handling file system changes?

Here is the scenario: I'm writing an app that will watch for any changes in a specific directory. This directory will be flooded with thousands of files a minute each with an "almost" unique GUID. The file format is this: GUID.dat where GUID == xxxxxxxxxxxxxxxxxxxxxxxxxxxxx (the internal contents aren't relevant, but it's just text da...

What is a race condition?

When writing multi-threaded applications, one of the most common problems experienced are race conditions. My question to the community, is: What is a race condition? How do you detect them? How do you handle them? And finally, how do you prevent them from occurring? ...

What is a deadlock?

When writing multi-threaded applications, one of the most common problems experienced are deadlocks. My question to the community, is: What is a deadlock? How do you detect them? Do you handle them? And finally, how do you prevent them from occurring? ...

What is a semaphore?

A semaphore is a programming concept that is frequently used to solve multi-threading problems. My question to the community: What is a semaphore and how do you use it? ...

What is a mutex?

A mutex is a programming concept that is frequently used to solve multi-threading problems. My question to the community: What is a mutex and how do you use it? ...

File database suggestion with support for multiple concurent users.

I need a database that could be stored network drive and would allow multiple users (up to 20) to use it without any server software. I'm considering MS Access or Berkeley DB. Can you share your experience with file databases? Which one did you use, did you have any problems with it? ...

Concurrent collections in C#

I'm looking for a way of getting a concurrent collection in C# or at least a collection which supports a concurrent enumerator. Right now I'm getting an InvalidOperationException when the collection over which I'm iterating changes. I could just deep copy the collection and work with a private copy but I'm wondering if there is perhap...

Java object allocation overhead

I am writing an immutable DOM tree in Java, to simplify access from multiple threads.* However, it does need to support inserts and updates as fast as possible. And since it is immutable, if I make a change to a node on the N'th level of the tree, I need to allocate at least N new nodes in order to return the new tree. My question is,...

Programmatically determine which Java thread holds a lock

Is it possible at runtime to programmatically check the name of the Thread that is holding the lock of a given object? ...

Return collection as read-only

I have an object in a multi-threaded environment that maintains a collection of information, e.g.: public IList<string> Data { get { return data; } } I currently have return data; wrapped by a ReaderWriterLockSlim to protect the collection from sharing violations. However, to be doubly sure, I'd like to return the col...

How do I tell a multi-core / multi-CPU machine to process function calls in a loop in parallel?

I am currently designing an application that has one module which will load large amounts of data from a database and reduce it to a much smaller set by various calculations depending on the circumstances. Many of the more intensive operations behave deterministically and would lend themselves to parallel processing. Provided I have a ...

Is a bool read/write atomic in C#

Is accessing a bool field atomic in C#? In particular, do I need to put a lock around: class Foo { private bool _bar; //... in some function on any thread (or many threads) _bar = true; //... same for a read if (_bar) { ... } } ...

Tools to test/debug/fix PHP concurrency issues?

I find myself doing some relatively advanced stuff with memcached in PHP. It's becoming a mental struggle to think about and resolve race conditions and concurrency issues caused by the lock-free nature of the cache. PHP seems pretty poor in tools when it comes to concurrency (threads, anyone?), so I wonder if there are any solutions ou...

Active threads in ExecutorService

Any ideas how to determine the number of active threads running in ExecutorService? ...