concurrency

Do the ‘up to date’ guarantees for values of Java's final fields extend to indirect references?

The Java language spec defines semantics of final fields in section 17.5: The usage model for final fields is a simple one. Set the final fields for an object in that object's constructor. Do not write a reference to the object being constructed in a place where another thread can see it before the object's constructor is finished. I...

Java - when to use notify or notifyAll?

Why does java.lang.Object have two notify methods - notify and notifyAll? It seems that notifyAll does at least everything notify does, so why not just use notifyAll all the time? If notifyAll is used instead of notify, is the program still correct, and vice versa? What influences the choice between these two methods? ...

Is there a concurrent container library for C++

Possible Duplicate: Is there a production ready lock-free queue or hash implementation in C++ I'm looking for implementations of lock-free containers: Queue Stack Hash Map etc... How about blocking containers: Blocking Queue Blocking Stack Are there any good libraries out there? I would like to refrain from writing the...

Locking database edit by key name

I need to prevent simultaneous edits to a database field. Users are executing a push operation on a structured data field, so I want to sequence the operations, not simply ignore one edit and take the second. Essentially I want to do synchronized(key name) { push value onto the database field } and set up the synchronized item so ...

definition of wait-free (referring to parallel programming)

In Maurice Herlihy paper "Wait-free synchronization" he defines wait-free: "A wait-free implementation of a concurrent data object is one that guarantees that any process can complete any operation in a finite number of steps, regardless the execution speeds on the other processes." www.cs.brown.edu/~mph/Herlihy91/p124-herlihy.pdf Let'...

Self-updating collection concurrency issues

I am trying to build a self-updating collection. Each item in the collection has a position (x,y). When the position is changed, an event is fired, and the collection will relocate the item. Internally the collection is using a “jagged dictionary”. The outer dictionary uses the x-coordinate a key, while the nested dictionary uses the y-...

Groovy concurrency: A better way to aggregate results semantically?

I need to call a number of methods in parallel and wait for results. Each relies on different resources, so they may return at different times. I need to wait until I receive all results or time out after a certain amount of time. I could just spawn threads with a reference to a shared object via a method call, but is there a better, mo...

Database concurrency issue in .NET application

If userA deleted OrderA while userB is modifying OrderA, then userB saves OrderA then there is no order in the database to be updated. My problem is there is no error! The SqlDataAdapter.Update succeeds and returns a "1" indicating a record was modified when this is not true. Does anybody know how this is supposed to work, thanks. ...

Does OpenCL allow concurrent writes to same memory address?

Is two (or more) different threads allowed to write to the same memory location in global space in OpenCL? The write is always changing a uchar from 0 to 1 so the outcome should be predictable, but I'm getting erratic results in my program, so I'm wondering if the reason can be that some of the writes fail. Could it help to declare the ...

Java Concurrency : Synchronized(this) => and this.wait() and this.notify()

Hello Experts, I would appreciate your help in understand a "Concurrency Example" from: http://forums.sun.com/thread.jspa?threadID=735386 Qute Start: public synchronized void enqueue(T obj) { // do addition to internal list and then... this.notify(); } public synchronized T dequeue() { while (this.size()==0) { th...

Techniques for modeling a dynamic dataflow with Java concurrency API

Is there an elegant way to model a dynamic dataflow in Java? By dataflow, I mean there are various types of tasks, and these tasks can be "connected" arbitrarily, such that when a task finishes, successor tasks are executed in parallel using the finished tasks output as input, or when multiple tasks finish, their output is aggregated in ...

Data access strategy for a site like SO - sorted SQL queries and simultaneous updates that affect the sort?

I'm working on a Grails web app that would be similar in access patterns to StackOverflow or MyLifeIsAverage - users can vote on entries, and their votes are used to sort a list of entries based on the number of votes. Votes can be placed while the sorted select queries are being performed. Since the selects would lock a large portion ...

Android 2.1 GoogleMaps ItemizedOverlay ConcurrentModificationException

Hi, I cannot figure out the origin of the ConcurrentModificationException. In my activity I'm calling updateMapOverlay(). I'm also calling updateMapOverlay() inside another Thread (a TimerTask) that is invoked on regular intervals. I'm taking the appropriate locks when invoking updateMapOverlay() from both the threads. Is this proble...

Occasional InterruptedException when quitting a Swing application

I recently updated my computer to a more powerful one, with a quad-core hyperthreading processor (i7), thus plenty of real concurrency available. Now I'm occasionally getting the following error when quitting (System.exit(0)) an application (with a Swing GUI) that I'm developing: Exception while removing reference: java.lang.Interrupted...

Webserver concurrent connections

Where can I get statistics of concurrent connections that can be handled by Apache and IIS? Which one will serve more requests in peak times? Thank you, Sri ...

Controlling race condition at startup.

I have some code that I want to have some one time initialisation performed. But this code doesn't have a definite lifecycle, so my logic can be potentially invoked by multiple threads before my initialisation is done. So, I want to basically ensure that my logic code "waits" until initialisation is done. This is my first cut. public c...

How is spin lock implemented under the hood?

This is a lock that can be held by only one thread of execution at a time. An attempt to acquire the lock by another thread of execution makes the latter loop until the lock is released. How does it handle the case when two threads try to acquire the lock exactly the same time? I think this question also applies to variou...

LINQ to SQL: Issue with concurrency

I’m working on a sandwich ordering app in ASP.NET MVC, C# and LINQ to SQL. The app revolves around the user creating multiple custom-made sandwiches from a selection of ingredients. When it comes to confirming the order I need to know that there’s enough portions of each ingredient to fulfil all the sandwiches in the user’s order before...

Asynchrous calls cause StaleObjectStateException

Hi all, I'm struggling with a Grails service. The service gets AJAX calls from the clients and behaves like a simple local cache for remote objects: void **someCallFromClient**() { // extract params def results = remoteService.queryService(params) results.each{ // try to fetch result object from local DB def obj = Some...

Strategy for handling user input as files

I'm creating a script to process files provided to us by our users. Everything happens within the same UNIX system (running on Solaris 10) Right now our design is this User places file into upload directory Script placed on cron to run every 10 minutes. Script looks for files in upload directory, processes them, deletes immediately af...