I have an application that is unresponsive and seems to be in a deadlock or something like a deadlock. See the two threads below. Notice that the My-Thread@101c thread blocks AWT-EventQueue-0@301. However, My-Thread has just called java.awt.EventQueue.invokeAndWait(). So AWT-EventQueue-0 blocks My-Thread (I believe).
My-Thread@101c,...
How can I return a java.util.concurrent.Future object with a Receipt object and only use the @javax.ejb.Asynchronous annotation?
And do I need any extra configuration to let Spring handle ejb annotations?
I don't want to write any concurrency logic myself.
Here's my attempt that doesn't work:
@Asynchronous
public Future<Receipt> exec...
I have a windows service that runs every 10 seconds ... each time it runs, it takes some test data, modifies it and persists it to the database using the EntityFramework. However, on every second run, when I try to persist the change I get the following Optimistic Concurrency Exception:-
Store update, insert, or delete statement affe...
I am trying to update entries in a ConcurrentDictionary something like this:
class Class1
{
public int Counter { get; set; }
}
class Test
{
private ConcurrentDictionary<int, Class1> dict =
new ConcurrentDictionary<int, Class1>();
public void TestIt()
{
foreach (var foo in dict)
{
foo...
If I create a scheduled task by calling ScheduledExecutorService.schedule(), it never quits after execution, is it a JDK bug, or I just miss something?
note: doSomething() is empty method below.
public static void doSomething() {
}
public static void main(String[] args) {
ScheduledFuture scheduleFuture =
Executors.newSingle...
Is there example implementation of Peterson algorithm for mutual exclusion in Java?
...
What happens if a RCP structure obtained by calling clnt_create() is used by several threads versus a remote client?
For example...
clnt_create() => A: RCP Client structure
Thread 1 => Use A and call service_1() versus client 1;
Thread 2 => Use A and call service_2() versus client 1;
Sometimes thread 2 will use A when thread 1 is still...
Let me describe the system. There are several mobile devices, each independent from each other, and they are generating content for the same record id.
I want to avoid generating the same content for the same record on different devices, for this I though I would use a random and make it so too cluster the content pool based on these ran...
I'm trying to write a reusable component in Groovy to easily shoot off emails from some of our Java applications. I would like to pass it a List, where Email is just a POJO(POGO?) with some email info. I'd like it to be multithreaded, at least running all the email logic in a second thread, or make one thread per email.
I am really ...
Clojure is said to be a language that makes multi-thread programming easier.
From the Clojure.org website:
Clojure simplifies multi-threaded
programming in several ways.
Now I'm looking for a non-trivial problem solved in Java and in Clojure so I can compare/contrast their simplicity. Anyone?
...
For single-producer, single-consumer should I use a BlockingCollection or a ConcurrentQueue?
Concerns:
My goal is to pull up to 100 items at a time and send them as a batch to the next step.
If I use a ConcurrentQueue, I have to manually cause it to go asleep when there is no work to be done. Otherwise I waste CPU cycles on spinning.
...
In Java, the concurrent mode failure means that the concurrent collector failed to free up enough memory space form tenured and permanent gen and has to give up and let the full stop-the-world gc kicks in. The end result could be very expensive. I understand this concept but never had a good comprehensive understanding of A) what could c...
I've installed apache server 2.2 on a VPS server, when i want to download a file via HTTP from my VPS using IDM, it only opens 8 of 16 possible connections (for many servers it opens all 16 connections).
Is there any configuration to increase number of concurrent connections to a file in apache (or in my VPS) or this is a network or fire...
I have programmed a simple app that every X minutes checks if an image has changed in several websites and downloads it. It's very simple: downloads image header, make some CRC checks, downloads the file, stores in a MySQL database some data about each image and process next item...
This process takes about 1 minute to complete.
The pr...
Dear all,
we are receiving about 10000 messages per hour. We store them as individual files in hourly directories on an ext3 filesystem. The file name includes a sequence number. We use rsync to mirror these files every 20 seconds at another location (via a SAN, but that doesn't matter).
Sometimes an rsync run picks up files n-3, n-2, ...
I plan to use dom4j DOM Document as a static cache in an application where multiples threads can query the document.
Taking into the account that the document itself will never change, is it safe to query it from multiple threads?
I wrote the following code to test it, but I am not sure that it actually does prove that operation is sa...
I'm using table with a counter to ensure unique id's on a child element.
I know it is usually better to use a sequence, but I can't use it because I have a lot of counters (a customer can create a couple of buckets and each of them needs to have their own counter, they have to start with 1 (it's a requirement, my customer needs "human r...
I have used AtomicLong many times but I have never needed to use AtomicReference
It seems that AtomicReference does either (I copied this code from another stackoverflow
question):
public synchronized boolean compareAndSet(List<Object> oldValue, List<Object> newValue) {
if (this.someList == oldValue) {
// someList could be...
I have a case where many threads all concurrently generate data that is ultimately written to one long, serial file stream. I need to somehow serialize these writes so that the stream gets written in the right order.
ie, I have an input queue of 2048 jobs j0..jn, each of which produces a chunk of data oi. The jobs run in parallel on, s...
For an algorithm I'm working on I tried to develop a blacklisting mechanism that can blacklist arrays in a specific way: If "1, 2, 3" is blacklisted "1, 2, 3, 4, 5" is also considered blacklisted.
I'm quite happy with the solution I've come up with so far. But there seem to be some serious problems when I access a blacklist from multiple...