concurrency

Can't safely lock a value of a ConcurrentDictionary

Hi, I asked a question about this yesterday and got lots of helpful feedback (thanks!) but I don't think I gave enough information in the question - hence, another. I have two threads which concurrently read two files. They put the information from these files into two ConcurrentQueues. Another two threads then come along, dequeue item...

Custom cancel for FutureTask

I have implemented custom cancellation logic as described in Concurrency in Practice. Encapsulating nonstandard cancellation in a task with newTaskFor. This works fine and I can call cancel on the a future and the task is cancelled as expected. I need to be able to destroy my executor service which i am using by calling "shutdownNow"...

Interlocked class

Hello everyone. Up to this point I used lock(object) construction for acces to shared variables. After reading msdn article about Interlocked The Increment and Decrement methods increment or decrement a variable and store the resulting value in a single operation. On most computers, incrementing a variable is not an atomic operation,...

SharePoint concurrency issues (users accidentally checking out older versions of files)

This is a strange issue that I'm wondering if others have encountered when editing documents in a SharePoint document library. Basic problem is as follows: User1 edits document X User1 checks in document X (say this new version is version 12) Days later, User2 checks out document X, but the document they begin editing is actually vers...

Using MapMaker#makeComputingMap to prevent simultaneous RPCs for the same data

We have a slow backend server that is getting crushed by load and we'd like the middle-tier Scala server to only have one outstanding request to the backend for each unique lookup. The backend server only stores immutable data, but upon the addition of new data, the middle-tier servers will request the newest data on behalf of the cli...

java.util.concurrent: Should I synchronize to avoid visiblity issues among threads?

I wonder if when using any of the java.util.concurrent classes I still need to synchronize access on the instance so to avoid visibility issues. In short the question is: When using an instance of java.util.concurrent, is it possible that one thread modify the instance (i.e., put an element in a concurrent hashmap) and a subsequent th...

How do I update a JTable based on a notification received from a long-running task in other thread?

I've an Observer TableModel which listens to some changes, performed in the database, and when so the update method below is called. My problem is, how should I prevent errors like: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1 at java.util.ArrayList.RangeCheck(ArrayList.java:547) at java.util.ArrayList.set(ArrayList.java:337) ...

c++ fstream concurrent access

What will happen if files are accessed concurrently from different processes/threads? I understand there is no standard way of locking a file, only os specific functions. In my case files will be read often and written seldom. Now if A open a file for reading (ifstream) and starts reading chunks. And B opens the same file for writing (o...

Is there any (unbounded) fair blocking queue in java?

Is there any implementation of blocking queue which guarantees fair take() operation if multiple consumers are removing element from the same queue. I checked LinkedBlockingQueue, LinkedTransferQueue and looks like both of them are unfair. ArrayBlockingQueue provides fair operation but its bounded. ...

Asserting order of synchronization in Java

In highly concurrent systems, it can be difficult to be confident that your usage of locks is correct. Specifically, deadlocks can result if locks are acquired in an order that was not expected while being acquired in the proper order in another thread. There are tools (e.g. Coverity) which can do static analysis on a code base and loo...

Concurency and AJAX applications

I have an application wich is multi-user and only one user can do a specific action and has to wait for another user to finish is task. Right now it's implemented with spin lock like so: while(($Application = Application::LoadLock($_SESSION['userid'], $_SESSION['DB'])) === false) usleep(100000); But this way the transition aren'...

Read-only thread safety

What is mean term "Read-only thread safety" Can anyone post some code example? ...

How to test concurrent access to resource (cache) in Perl?

How can I test that resource (file based cache for caching output of a webapp in Perl) behaves sanely under concurrent access to said shared resource? I wrote a simple file-based cache, written in Perl, which uses locking to serialize write access, i.e. to have only one process that (re)generates cache entry. This cache is to be used...

Breakdown of Threads used by a JApplet

I've been spending a great deal of time trying to understand this. I created a JApplet that used Thread.sleep() in a loop to animate the applet. But when I tried to run the Applet the screen stayed blank. When I draw the animations in a separate thread and call repaint, the applet works perfectly. I've seen many explanations of why th...