concurrency

Are single-threaded applications a dead technology?

I just bought a new, sub-US$1,000 laptop, one aimed squarely at the consumer, non-developer market and, looking over the specs, was surprised to find that it came standard with a dual-core processor. This led me to the question: with multicore machines becoming the norm, is it ever correct to write a single-threaded application anymore?...

LINQ to XML updates - how does it handle multiple concurrent readers/writers?

I have an old system that uses XML for it's data storage. I'm going to be using the data for another mini-project and wanted to use LINQ to XML for querying/updating the data; but there's 2 scenarios that I'm not sure whether I need to handle myself or not: 1- If I have something similar to the following code, and 2 people happen to hit...

java.util.ConcurrentLinkedQueue

I want to use java.util.ConcurrentLinkedQueue as a non-durable queue for a Servlet. Here's the blurb from the javadoc for the class. An unbounded thread-safe queue based on linked nodes. A ConcurrentLinkedQueue is an appropriate choice when many threads will share access to a common collection. This queue does not permit null element...

Re-creating threading and concurrency knowledge in increasingly popular languages

I am primarily a Java developer, and I've been reading a lot of in-depth work on threads and concurrency. Many very smart people (Doug Lea, Brian Goetz, etc) have authored books on these topics and made contributions to new concurrency libraries for Java. As I start to learn more about Python, Ruby, and other languages, I'm wondering: ...

C# concurrency, locking and dictionary objects

I have a bunch of DB entities that are loaded into DB objects. The same DB entity may be loaded into more than DB object. Periodically a DB entity will require special processing. This processing must be performed by one thread at a time. Locking is in order here. EDIT: Important note: the process calls a slow web service. This ...

Locking a MySQL database so only one person at once can run a query?

I am having a few issues when people are trying to access a MySQL database and they are trying to update tables with the same information. I have a webpage written using PHP. In this webpage is a query to check if certain data has been entered into the database. If the data hasn't, then i proceed to insert it. The trouble is that if two...

Multithreading and concurency with C#

In a Windows Form window, multiple events can trigger an asynchronous method. This method downloads a file and caches it. My problem is that I want that method to be executed once. In other words, I want to prevent the file to be downloaded multiple times. If the method downloading the file is triggered twice, I want the second call to...

Thread safety of simultaneous updates of a variable to the same value

Is the following construct thread-safe, assuming that the elements of foo are aligned and sized properly so that there is no word tearing? If not, why not? Note: The code below is a toy example of what I want to do, not my actual real world scenario. Obviously, there are better ways of coding the observable behavior in my example. u...

Limit number of concurrent connections in Apache2

Is there a way I can limit the number of concurrent connections to the Web Application running on my Apache Server. My server version is Apache 2.2.11 ...

java designing tasks in concurrent mechanism

I am coming up with a design for a task based multi-thread java 1.5 system. Tasks will generally interact with a collection to determine failed or successfull match events. Based on the outcome, another task may be queued for IO transactions to inform clients and/or store important information about the transaction. Java provides a ...

What are synchronizing strategies for Prevayler?

Prevayler guarantees that all the writes ( through its transactions) are synchronized. But what about reads? Is it right that dirty reads are possible if no explicit synchronizing is used (in user code)? Are they possible if a business object is read as: // get the 3rd account Accont account = (Bank)prevayler.prevalentSystem().getAc...

Is there a 'standard' read/write lock implementation for ruby?

Does anyone know of an existing ruby implementation of a read/write lock - http://en.wikipedia.org/wiki/Readers-writer_lock? Preferably this would be in a popular library or some other implementation that's been used by enough people that it's fairly bulletproof at this point. ...

What is the most frequent concurrency problem you've encountered in Java?

This is a poll of sorts about common concurrency problems in Java. An example might be the classic deadlock or race condition or perhaps EDT threading bugs in Swing. I'm interested both in a breadth of possible issues but also in what issues are most common. So, please leave one specific answer of a Java concurrency bug per comment an...

What's the right pattern for unique data in columns?

I've a table [File] that has the following schema CREATE TABLE [dbo].[File] ( [FileID] [int] IDENTITY(1,1) NOT NULL, [Name] [varchar](256) NOT NULL, CONSTRAINT [PK_File] PRIMARY KEY CLUSTERED ( [FileID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS...

Java ReentrantReadWriteLocks - how to safely acquire write lock?

I am using in my code at the moment a ReentrantReadWriteLock to synchronize access over a tree-like structure. This structure is large, and read by many threads at once with occasional modifications to small parts of it - so it seems to fit the read-write idiom well. I understand that with this particular class, one cannot elevate a re...

What programming language are you using today for multicore platform?

I was reading this blog post http://www.cilk.com/multicore-blog/bid/8097/Don-t-get-caught-with-your-multicore-pants-down and got me asking this question. 4-cores or 8-cores will be a common thing in 12-24 months time and I got a chill realizing that I don't have a answer for that yet. ...

How can I synchronize two processes accessing a file on a NAS?

Here's the thing: I have two applications, written in C++ and running on two machines with different OS (one Linux and one Windows). One of this process is in charge of updating an XML file on a NAS (Network Attached Storage) while the other one reads this file. Is it possible to synchronize these two processes in order to avoid readin...

How/why do functional languages (specifically Erlang) scale well?

I have been watching the growing visibility of functional programming languages and features for a while. I looked into them and didn't see the reason for the appeal. Then, recently I attended Kevin Smith's "Basics of Erlang" presentation at Codemash. I enjoyed the presentation and learned that a lot of the attributes of functional p...

Does a running thread in an object prevent it from being garbage collected in java ?

Given the code: new Thread(new BackgroundWorker()).start(); Intuitively it feels like the BackgroundWorker instance should be safe from GC until the thread exits, but is this the case ? And why ? Edit: All this heat is basically generated by me asking at least two different questions in the same post. The question in the title has...

Collections optimized for concurrency in .Net

In the java world there is a set of classes optimized for concurrent tasks. I assume there is something similar in .Net, but after a quick search in MSDN I couldn't find anything. I was looking for a queue with fairness policy to be used in consumer/producer situations. Thanks. ...