concurrency

Concurrency Question

I am writing an application in java (1.6) using swing. I currently have a JXBusyLabel on a JXLayer over the content area of my program acting as a busy indicator. I want to provide a way to allow others working with me to create a task that pops up the busy label while it's executing. The catch is, the task must be cancel-able. What is t...

How to interrupt a BlockingQueue which is blocking on take()?

I have a class that takes objects from a BlockingQueue and processes them by calling take() in a continuous loop. At some point I know that no more objects will be added to the queue. How do I interrupt the take() method so that it stops blocking? Here's the class that processes the objects: public class MyObjHandler implements Runna...

best practices for database + resultset concurrency (both UI and control issues)

I'm working on a viewer program that formats the contents of a database. So far it's all been read-only, and I have a Refresh button that re-queries the database if I want to make sure to use current data. Now I'm looking at changing the viewer to an editor (read-write) which involves writing back to the database, and am realizing there...

How does CCR & DSS toolkit model compare to other scalability & concurency approaches?

I'm interested to comparison between various approaches to scalability & concurrency including CCR & DSS framework model. I would be especially interested with comparison with Hadoop and Erlang style concurency ...

Concurrently read from a single file

I have the following problem situation. A bunch of data is split across 10k small files (approx. 8-16 kib each). Depending on user input, I have to load these as fast as possible, and process them. More precisely, each data packet can be split into 100-100k files, and there are approximately 1k data packets. Most of them are the smaller ...

[java thread safety] Object visibility across threads

Hi, I have a general doubt regarding publishing data and data changes across threads. Consider for example the following class. public class DataRace { static int a = 0; public static void main() { new MyThread().start(); a = 1; } public static class MyThread extends Thread { public void run() { // Access a...

When and how should I use a ThreadLocal variable?

When should I use a ThreadLocal variable? How is it used? ...

Any suggestions for a program or small project to learn about concurrency in Java?

I'm aiming to learn about concurrency in Java. Currently my state of knowledge is poor. I'm pretty sure I know what "volatile" means. I sort of know what "synchronized" means. Sometimes. I've never written code that starts threads or manages them. Outside of this issue, I feel confident and at home working in Java. I'm looking for...

What is the reasoning behind the double call to WeakHashMap.put( .. ) ?

This blog post demonstrates a way to implement a mutex per string id idiom. The String ids used are to represent HttpSession ids. Why do we need to wrap a WeakReference around the Mutex instances ? Isn't it better to just create a Map from String -> Mutex ? Why do we need to call put twice ? public Mutex getMutex( String id ) { ...

Application area of lock-striping

The ConcurrentHashMap of JDK uses a lock-striping technique. It is a nice idea to minimize locking overhead. Are there any other libraries or tools that take advantage of it? For example, does database engine use it? If the technique is not so much useful in other areas, what is the limitation of it? ...

How to performance tune when you have heavy concurrency on an Oracle table

On an Oracle 10g table which has heavy read/write we occassionally get a huge spike in concurrency quoting "latch library cache" using all the CPU. What approaches can we take to lessen the load within the database. We've seen stuff about free lists and increasing those. Any other opinions. ...

BlockingQueue - blocked drainTo() methods

BlockingQueue has the method called drainTo() method but it is not blocked. I need a blocking queue that I want to blocked but also able to retrieve queued-object in a single method. Object first = blockingQueue.take(); if ( blockingQueue.size() > 0 ) blockingQueue.drainTo( list ); I guess the above code will work but I'm look...

WCF Concurrent requests piling up on the server when using WSHttpBinding

I have a WCF client/server app which is communicating over HTTP using the WSHttpBinding. Server Setup: self-hosting, using the standard WCF ServiceHost. My actual service class is attributed as: [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, InstanceContextMode = InstanceContextMode.PerSession, UseSynchronizationConte...

Any multi-core advantage here ?

Let me frame it this way.. "Say I have an application server running on a single core Intel processor & serving 200 concurrent users. Will moving the hardware to a dual core system enable my application server to now serve say 350 concurrent users" ? The base question I'm hoping to address is - "Can addition of extra processor cores h...

J2EE concurrency & locking

I have a MDB (Message driven bean) that receives messages with String which represent a word. Also I have a table in the database. The MDB should store in the table, the words and the number of times each word was received (counter). The problem is that to get better performance the MDB started in many instances and when the same new wo...

Preferred database/webapp concurrency design when multiple users can edit the same data

I have a ASP.NET C# business webapp that is used internally. One issue we are running into as we've grown is that the original design did not account for concurrency checking - so now multiple users are accessing the same data and overwriting other users changes. So my question is - for webapps do people usually use a pessimistic or op...

Concurrency with Linq To Sql Stored Procedures

I come from the asp.net world where we'd use an objectdatasource, hooked up to data access layer, and set it's ConflictDetection property to "CompareAllValues". There is an OldValuesParameterFormatString on the ObjectDataSource that you use to identify old value parameters. The sql procedure that does an update would then require both n...

Looking for good analogy/examples for monitor verses semaphore.

A monitor is supposed to solve problems with semaphores in concurrent environments. I'm looking for a good analogy using a monitor verses semaphore. Please use information for the analogy: 4 tasks (TaskA, TaskB, TaskC, TaskD) 1 variable varX Each Task wants to manipulate varX based on some event. ...

How to debug ConcurrentModificationException?

I encountered ConcurrentModificationException and by looking at it I can't see the reason why it's happening; the area throwing the exception and all the places modifying the collection are surrounded by synchronized (this.locks.get(id)) { ... } // locks is a HashMap<String, Object>; I tried to catch the the pesky thread but all I ...

Restore of data replicated with erasure-coding

I need your help on the design of the restore-procedure in a backup system I'm building. The prerequisites are the following: A restore can be made of one or several files. A file consists of 1 or more data-blocks (on average 16mb in size, minimum 4mb maximum 64mb). A data-block is replicated using erasure coding into replication-bloc...