concurrency

newCachedThreadPool() V/s newFixedThreadPool

newCachedThreadPool() V/s newFixedThreadPool(...) when to use and which is better in terms of resource utilisation? ...

Simple Producer-Consumer problem, but the producer updates the old buffers.

Hi everybody, Let's say I have two buffers. Producer fills buffer #1, then fills buffer #2. The consumer consumes one buffer a time, and it's very slow. While it is consuming buffer #1, the producer is ready to fill another buffer, but they are all full, and the consumer hasn't finished yet with #1. So, the producer waits. Instead of w...

Does this Scala actor block when creating new actor in a handler?

I have the following piece of code: actor { loop { react { case SomeEvent => //I want to submit a piece of work to a queue and then send a response //when that is finished. However, I don't want *this* actor to block val params = "Some args" val f: Future[Any] = myQueue.submitWork( para...

Migrating from Java concurrency to Scala concurrency

I have a fairly standard mechanism in Java for solving the problem: Work items must be scheduled to execute at a particular time Each work item must then wait on a condition becoming true Work items should be cancellable The solution I use is as follows: Have a single-threaded scheduler to schedule my work items Have an ExecutorSe...

How to test for thread safety

Do you have any advices how to test a multithreaded application? I know, threading errors are very difficult to catch and they may occur at anytime - or not at all. Tests are difficult and the results are never for sure. Certainly it is best to carefully design and program the concurrent modules. Nevertheless - I do not want to leave ou...

Updating a single field with Linq to SQL - Can I just disable all concurrency logic?

Yes, this subject is covered on hundreds of posts all over the net, and yet I still haven't found the one that doesn't involve loading an entire entity (sometimes serialized) just to change a single field. Some had suggested that changing "Update Check" on all properties of the entities would resolve this, but so far I'm still getting Ch...

is there a concurrency with UPDATE count=count+1?

Hey guys i wanted to know, will i run into any concurrency problem with this? This is NOT in a transaction. This code is for Sqlite(prototype), but i plan to use it with either MySql or a SQL from MS command.CommandText = "UPDATE tag_name SET count = count+1 "+ "WHERE tagid=@tagid"...

Is this SQL code concurrent safe?

I am pretty sure this code is fine. I wanted to know what you guys think about the insertMediaTags function (2nd func). The things i am worried about is the below concurrent safe? and if insertMediaTags is optimize enough? note it is in a transaction due to first func but it is also in a loop which could mean its bad? I am open to any c...

What is a good hardware setup for programming concurrent and distributed applications?

I don't have the money to build my own uber Blade system but I would like to get into concurrent and distributed programming (think CCR/DSS, Hadoop, Project Voldemort etc.). I currently have a Q6600 with 4GB with some separate hdds but that's about it. While I can write multi-threaded programs I can not properly test distributed filesys...

Speeding up straggling idempotent tasks

I'm running multiple idempotent tasks to gather one batch of data. I found out that many times the computation is delayed significantly due to a couple of tasks out of a hundred. What I'd like is a way of watching these tasks and launching the stragglers again if they are significantly delayed. Is there a standard library or idiom for ...

What is transaction?

Well could someone provide a really simple (but not simpler than possible) explanation of transaction as applied to computing (even if copied from Wikipedia)? ...

Which Java blocking queue is most efficient for single-producer single-consumer scenarios

I'm working on a standard Java system with critical timing requirements for my producers (1/100s of ms matters). I have a producer placing stuff in a blocking queue, and a single consumer later picking up that stuff and dumping it to a file. The consumer blocks when data is not available. Obviously, blocking queue is the appropriate...

Is there a good podcast about concurrency?

Hi All, Concurrency is one of the hot topics on quite a few technology podcasts. Yet I couldn't find a podcast dedicated to concurrency programming fundamentals, techniques etc. If there's no podcast that specializes on concurrency which of technology podcasts highlights this topic best? ...

Concurrent multimap put and remove

This is a composed concurrent list multimap implementation. A lower-level implementation would be better, but more complex. Ignoring the O(n) removal in the sublist, is this the correct way to compose a ConcurrentMap and CopyOnWriteArrayList into a functional ConcurrentMultimap? Are there any unresolved data races? private final Concur...

LINQ :: Use static DataContext to prevent Concurrency Problem

Hi i am facing some problems in my project. when i try to update entity it gives me different type of errors. i read from net. these errors are because 1 - I am getting Object of entity class from method which creates DataContext locally and in update method id does not update because here another DataContext is created locally. (eve...

C# threading and Windows Forms

Is my approach to a responsive GUI with a background process correct? If not, please please critique and offer improvements. In particular, indicate what code could potentially suffer from a deadlock or race condition. The worker thread needs to be able to be cancelled and report it's progress. I didn't use a BackgroundWorker because...

Is synchronization necessary for unmodifiable maps?

I'm using JDK 1.4...so I don't have access to the nice concurrency stuff in 1.5+. Consider the following class fragment: private Map map = Collections.EMPTY_MAP; public Map getMap() { return map; } public synchronized void updateMap(Object key, Object value) { Map newMap = new HashMap(map); newMap.put(key, value); map...

Simplest possible voting/synchronization algorithm

What would be a simplest algorithm one or more people could use to decide who of them should perform some task? There is one task, which needs to be done only once, and one or more people. People can speak, that is, send messages one to another. Communication must be minimal, and all people use the exact same algorithm. One person sayin...

ASP.Net static objects

I'm trying to cache some information that I've retrieved from a database. I've decided to use a static List<> member to store the information. I know from my experience with List<> in multithreaded applications that I need to protect access to it with the lock statement. Do I treat any code in my Asp.Net code the exact same way? Will the...

Database Concurrency Needed when ADDING rows - Best Practice?

I'm working with an application that adds a new row to the database, based on the last row meeting a certain criteria. Is there a standard pattern for dealing with this type of problem, or do I simply need to lock the table? Here is an over-simplified visualization: A1 A2 A3 B1 B2 Using the visualization above, a web page loads up th...