concurrency

Programmatic deadlock detection in java

How can I programmatically detect that a deadlock has occurred in a Java program? ...

Reentrant locking.

A bit of help please, consider the bit of code below. public class Widget { public synchronized void doSomething() { ... } } public class LoggingWidget extends Widget { public synchronized void doSomething() { System.out.println(toString() + ": calling doSomething"); super.doSomething(); } } I ...

Classic file system problem - concurrent remote processing on a directory

I have an application that processes files in a directory and moves them to another directory along with the processed output. Nothing special about that. An interesting requirement was introduced: Implement fault tolerance and processing throughput by allowing multiple remote instances to work on the same file store. Additional...

Threading Building Blocks (TBB) for Qt-based CD ripper?

I am building a CD ripper application in C++ and Qt. I would like to parallelize the application such that multiple tracks can be encoded concurrently. Therefore, I have structured the application in such a way that encoding a track is a "Task", and I'm working on a mechanism to run some number of these Tasks concurrently. I could, of ...

When items change while being enumerated does it affects the enumeration?

Imagine that during a foreach(var item in enumerable) The enumerable items change. It will affect the current foreach? Example: var enumerable = new List<int>(); enumerable.Add(1); Parallel.ForEach<int>(enumerable, item => { enumerable.Add(item + 1); }); It will loop forever? ...

Looking for a framework that handles cancellation of HTTP Callables

I will be making multiple HTTP calls concurrently and want to allow the user to selectively cancel certain tasks if they take too long. A typical scenario: 1 task pulls twitter feed and another pulls facebook wall posts. The number of tasks is obviously variable, so the idea of a queue comes naturally. I've looked at ExecutorCompletionSe...

What will happen if records are deleted during the data retrieving process?

Let's say I have 6 records, and I set the fetch size as 2. [Id] [Name] 11 A <-- 1st fetch, start from 1 position 21 B 31 C <-- 2nd fetch, start from 3 position 41 D 51 E <-- 3rd fetch, start from 5 position 61 F If 1st user issues a "SELECT * from tablex", and 2nd user issue a "DELETE FROM tablex WHERE Id = 2. ...

What is Java's -XX:+UseMembar parameter

I see this parameter in all kinds of places (forums, etc.) and the common answer it help highly concurrent servers. Still, I cannot find an official documentation from sun explaining what it does. Also, was it added in Java 6 or did it exist in Java 5? (BTW, a good place for many hotspot VM parameters is this page) Update: Java 5 does ...

UNIX Portable Atomic Operations

Is there a (POSIX-)portable way in C for atomic variable operations similar to a portable threading with pthread? Atomic operations are operations like "increment and get" that are executed atomically that means that no context switch can interfere with the operation. In Linux kernel space, we have to atomic_t type, in Java we have the ...

Monitoring a long task in Javascript

Hello, I have a particular page that uses lots of widgets that have to be initialized by Javascript routines (around 400, it's a complex one). This takes some time (even 20 secs on slower machines). Now I was thinking I could show a progress indicator (a simple text field with a percentage label), instead of the page, but I discovered t...

Unable to attach a detached entity: "An object with the same key already exists in the ObjectStateManager".

Hi I am trying to attach an entity to the ObjectContext. When I do so, the following InvalidOperationException is thrown: An object with the same key already exists in the ObjectStateManager. The ObjectStateManager cannot track multiple objects with the same key. I checked in the object state manager and the item does not exist: //D...

A couple questions about Sutter's concurrency series on Dr. Dobbs

I have a couple questions about Sutter's concurrency series on Dr. Dobbs. 1) Sutter recommends moving code not requiring locks out of critical sections to (apart from increase the granularity of the critical section) keep from nesting critical sections, in the event that the nested calls themselves enter critical sections. I have always...

java array thread-safety

Are there any concurrency problems with one thread reading from one index of an array, while another thread writes to another index of the array, as long as the indices are different? e.g. (this example not necessarily recommended for real use, only to illustrate my point) class Test1 { static final private int N = 4096; fi...

Efficient copy from one file to another

I'm building a system in Java which has to copy a subset of a file into another file (not necessarily to the beginning of the file). I.e. I have the following parameters: File srcFile, File dstFile, long srcFileOffset, long dstFileOffset, long length Several threads could be reading from the same source-file and writing to the same des...

How does Subsonic handle concurrency?

Can somebody shed some light for me on how SubSonic 3.x handle concurrency? I checked out the document online but it's rather sparse at the moment. Any pointers and/or examples would be greatly appreciated. ...

What is the good ORM for .NET that does concurrency well?

I am looking for a well rounded ORM that handle concurrency with ease for .NET. It should also be threadsafe. Any recommendation? Pls elaborate why you choose this particular ORM. ...

Does this basic Java object pool work?

Does the following basic object pool work? I have a more sophisticated one based on the same idea (i.e. maintaining both a Semaphore and a BlockingQueue). My question is - do I need both Semaphore and BlockingQueue? Am I right that I don't need to do any synchronisation? import java.util.Collection; import java.util.concurrent.ArrayB...

When do you validate connections in a connection pool?

I'm implementing a connection pool in Java (i.e. a pool of java.sql.Connections). When should I check that connections are still valid? I don't want to do it before I lend them. Should I do it when they are returned? Every time? Is there a clever way to schedule checking? ...

SQL Server performance with many concurrent, long-running queries.

I'm wondering how executing many long-running queries simultaneously will impact SQL Server's ability to service each query in a timely fashion. [Edit] It wasn't my intention to be vague, it's more a hypothetical. Let's just assume the queries are select statements with some kind of predicate on tables with millions of rows. ...

Semaphore Counts

In .NET, is there a way to get the count on a semaphore. I don't need a threadsafe count, just a reasonable approximation so report the status on a GUI thread. Currently I'm using a dual-counter. The real semaphore and another variable that is incremented and decremented in sync, but this is annoying and error prone. ...