concurrency

Does lock(){} lock a resource, or does it lock a piece of code?

I'm still confused... When we write some thing like this: Object o = new Object(); var resource = new Dictionary<int , SomeclassReference>(); ...and have two blocks of code that lock o while accessing resource... //Code one lock(o) { // read from resource } //Code two lock(o) { // write to resource } Now, if i have two thr...

What's the upcoming Java concurrency library: jsr166y? jsr166z?

Hello! I wanted to play around with the upcoming concurrency library which is going to be included in Java 7 according to this website. It seems to be named JSR166. In most places its reference implementation is referred as jsr166y, while few resources call it jsr166z. I discovered two totally different javadocs for each reference im...

java.util.ConcurrentModificationException in JasperReports

We have a web application deployed to Websphere 6.1.0.19 on Windows. We occasionally see this ConcurrentModificationException on a few of our reports. We are using JasperReports 2.0.5 in production. The full stacktrace is following: java.util.ConcurrentModificationException at java.util.AbstractList$Itr.checkForComodification(...

Limit the number of concurrent connections from the server side?

I'm writing my own webserver and I don't yet handle concurrent connections properly. I get massive page loading lag due to inappropriately handling concurrent connections (I respond to SYN, but I lose the GET packet somehow. The browser retries after a while, but it takes 3 seconds!) I'm trying to figure out if there's a way to instru...

What Java Data Structure/Solution would best fit these requirements?

I need a java data structure/solution that meets these requirements. What best fits these? 1) Object's insertion order must be kept 2) Object's must be unique (These are database objects that are uniquely identified by a UUID). 3) If a newer object with the same ID is added, the older version of the object should be over-written/r...

What is mutex and semaphore in Java ? What is the main difference ?

What is mutex and semaphore in Java ? What is the main difference ? ...

NHibernate and sql timestamp columns as version

Hi, I've been racking my head trying to get Nhibernate to work with a byte array as version mapping to an sql timestamp. I'd implemented an IUserVersionType but Nhibernate was creating varbinary in the database rather than timestamp. Inspired by a blog post by Ayende recently on concurrency, I changed my mapping to specify the sql-type t...

Is it safe to use writeLock without readlock ?

Assuming this is a "singleton" implementation: Am I guaranteed that this will only call productCatalogLoader.load() once, and also that no nullpointers can happen ? Any way to make this simpler ? private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); private ProductCatalog productCatalog; public ProductCatalog get(...

Inter-Image communication in Smalltalk. Possible?

I have a graph-traversal problem that is beautifully and elegantly modeled in smalltalk, but it's too big (in terms of computation and storage) for one smalltalk image instance. So, I want to partition the problem across multiple instances. My question is, is there any good way to send messages between smalltalk instances. Kind of like...

Die you threadpoolexecutor

I have a java.util.concurrent.Execution service - a single threaded thread pool executor. I submit certain tasks to it. If the task throws an unchecked exception the thread dies but the service ensures that a new thread is spawned and subsequent tasks are performed in that. However I do not want this feature and still want to use a threa...

Time restricted service

Hi, i'm developing an app that make requests to the Musicbrainz webservice. I read in the musicbrainz manual to not make more than one request per second to the webservice or the client IP will be blocked. What architecture do you suggest in order to make this restriction transparent to the service client. I would like to call a me...

WaitForMultipleObjects in Java

What would be the most elegant way to implement a Win32 equivalent of WaitForMultipleObjects in Java (v6). A thread is sleeping until one of several events occur. When that happens, I want to process it and get back to sleep. No data is required, just an event. ...

how to do actors (erlang) in java?

I work on financial applications in Java and getting concurrency right is pain. Erlang and the actors model is supposed to be a good fit for massively concurrent applications but I can't figure out how to do it in Java. I know there are libraries such as Jetlang, FunctionalJava, kilim, etc., but they don't usually go beyond simplistic ...

Concurrency Checks in MSSQL (Alternatives to TSEQUAL)

I am working in development under SQL 2008, however I have a SQL 2000 database (in compatibility mode). There are several queries that are using the "TSEQUAL" function to do concurrency checks. It seems however that this function has been completely removed in SQL 2008 and these statements (sitting in SPROCS) no longer compile. What i...

Stop program execution until threads complete

I have a console application that inits 4 theads to perform a long task. I want my program to wait until the threads are complete, and then complete the program execution. Is there a way to stop the program from executing, letting the threads complete their job? ...

Testing for concurrency and/or transactional integrity in a web application with JMeter

I'm rather new to working with multiple threads in a database (most of my career has been spent on the frontend). Today I tried testing out a simple php app I wrote to store values in a mysql db using ISAM tables emulating transactions using Table Locking. I just wrote a blog post on the procedure Here: Testing With JMeter From my...

What's the opposite of "embarrassingly parallel"?

According to Wikipedia, an "embarrassingly parallel" problem is one for which little or no effort is required to separate the problem into a number of parallel tasks. Raytracing is often cited as an example because each ray can, in principle, be processed in parallel. Obviously, some problems are much harder to parallelize. Some may eve...

How do I implement task prioritization using an ExecutorService in Java 5?

I am implementing a thread pooling mechanism in which I'd like to execute tasks of varying priorities. I'd like to have a nice mechanism whereby I can submit a high priority task to the service and have it be scheduled before other tasks. The priority of the task is an intrinsic property of the task itself (whether I express that task ...

C++ Concurrent GET requests

I am writing a C++ application and would like to request several data files through a HTTP GET request simultaneously, where should I look to get started (needs to be cross-platform). Run Application Create a list of URLs { "http://host/file1.txt", "http://host/file2.txt", "http://host/file3.txt"} Request all the URLs simultaneously ...

Looking for Modern Java Threading / Concurrent programming Book

I'm looking for a modern java threading book. I've quite enjoyed reading Taming Java Threads by Allen Holub, but it's a little old now. That was 8 years ago. I want the knowledge develop concurrent and industry standard multi-threading applications. Suggestions? Or even online resources? ...