concurrency

Is there a JVM aimed at debugging concurrent software?

I've used Concurrent Pascal, a tool which helps debug concurrent algorithms because when it runs your code, it randomizes which thread to swap to at every possible step, trying out as many paths as possible. Is there a JVM that can do this? ...

How to synchronize multiple proccess in c through basic signal handling

Hi, people. For a academic exercise i have to implement a program in c for nix platform which is to synchronize multiple processes through signal handling, using only signal,pause,kill and fork basic functions. I searched google and have not found any clear example: I hope the wisdom of one of you will light my way. Thanks! ...

Keeping track of threads when creating them recursively

I'm currently working on some code for a course. I can't post the code but I'm permitted to talk about some high level concepts that I'm struggling with and receive input on them. Basically the code is a recursive DFS on a undirected graph that I'm supposed to convert to a concurrent program. My professor already specified that I should ...

Multithreaded java cache for objects that are heavy to create ?

I need to cache some objects with fairly heavy creation times, and I need exactly-once creation semantics. It should be possible to create objects for different CacheKeys concurrently. I think I need something that (under the hood) does something like this: ConcurrentHashMap<CacheKey, Future<HeavyObject>> Are there any existing open-s...

Java int concurrency ++int equivalent to AtomicInteger.incrementAndGet()?

Are these two equivalent? In other words, are the ++ and -- operators atomic? int i = 0; return ++i; AtomicInteger ai = new AtomicInteger(0); return ai.incrementAndGet(); ...

Is this technically thread safe despite being mutable?

Yes, the private member variable bar should be final right? But actually, in this instance, it is an atomic operation to simply read the value of an int. So is this technically thread safe? class Foo { private int bar; public Foo(int bar) { this.bar = bar; } public int getBar() { return bar; } } // ...

Best way to reuse a Runnable

I have a class that implements Runnable and am currently using an Executor as my thread pool to run tasks (indexing documents into Lucene). executor.execute(new LuceneDocIndexer(doc, writer)); My issue is that my Runnable class creates many Lucene Field objects and I would rather reuse them then create new ones every call. What's t...

Real World Examples of read-write in concurrent software

I'm looking for real world examples of needing read and write access to the same value in concurrent systems. In my opinion, many semaphores or locks are present because there's no known alternative (to the implementer,) but do you know of any patterns where mutexes seem to be a requirement? In a way I'm asking for candidates for the s...

ASP.NET MVC Concurrency with RowVersion in Edit Action

I'm wanting to do a simple edit form for our Issue Tracking app. For simplicity, the HttpGet Edit action looks something like this: // Issues/Edit/12 public ActionResult Edit(int id) { var thisIssue = edmx.Issues.First(i => i.IssueID == id); return View(thisIssue); } and then the HttpPost action looks ...

Why does this method throw an IllegalMonitorStateException?

public static synchronized void main(String[] args) throws InterruptedException { Thread t = new Thread(); t.start(); System.out.print("X"); t.wait(10000); System.out.print("Y"); } What is the problem with this method? How can I avoid such problems from now on? ...

Why wait should always be in synchronized block

Hi gents, We all know that in order to invoke Object.wait() , this call must be placed in synchronized block,otherwise,IllegalMonitorStateException is thrown.But what's the reason for making this restriction?I know that wait() releases the monitor, but why do we need to explicitly acquire the monitor by making particular block synchroni...

Java - Multithreading

I have a question... Can we call thread_object.start() from within a constructor ? Is this approach a good idea ? Thanks. ...

SQLite how to use perl DBI to return SQLite database waiting status?

Hi! I used BEGIN EXCLUSIVE for my write transaction so that the other users connect to the database at the same time will have to wait. My question is "Is there a way to track how long the script has been waiting before timeout"? I would like to return either a "database locked" or "sqlite busy" message to a variable in my script and ex...

Queue implementation with blocked 'take()' but with eviction policy

Is there an implementation with a blocking queue for take but bounded by a maximum size. When the size of the queue reaches a given max-size, instead of blocking 'put', it will remove the head element and insert it. So put is not blocked() but take() is. One usage is that if I have a very slow consumer, the system will not crash ( run...

What are Erlang processes behind the scenes?

I've got very limited knowledge about Erlang, but as far as I understand, it can spawn "processes" with a very low cost. So I wonder, what are those "processes" behind the scenes? Are they Fibers? Threads? Continuations? ...

Should I Put Critical Section While Getting Connection from OCCI Environment

Hello, I'm writing a multi-threaded application. My worker threads get connection from an environment object as follows:. //EnterCriticalSection(&cs); conn = env->createConnection(username, password, connStr); //LeaveCriticalSection(&cs); For concurrency, should the connection be created in a critical section or not? Does the env nee...

Can you dynamically resize a java.util.concurrent.ThreadPoolExecutor while it still has tasks waiting

I'm working with a java.util.concurrent.ThreadPoolExecutor to process a number of items in parallel. Although the threading itself works fine, at times we've run into other resource constraints due to actions happening in the threads, which made us want to dial down the number of Threads in the pool. I'd like to know if there's a way to ...

volatile keyword seems to be useless?

import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicInteger; public class Main implements Runnable { private final CountDownLatch cdl1 = new CountDownLatch(NUM_THREADS); private volatile int bar = 0; private AtomicInteger count = new AtomicInteger(0); private static final int NUM_THREADS = ...

PHP running as a FastCGI application (php-cgi) - how to issue concurrent requests?

EDIT: Update - scroll down EDIT 2: Update - problem solved Some background information: I'm writing my own webserver in Java and a couple of days ago I asked on SO how exactly Apache interfaces with PHP, so I can implement PHP support. I learnt that FastCGI is the best approach (since mod_php is not an option). So I have looked at the ...

Are there any concerns I should have about storing a Python Lock object in a Beaker session?

There is a certain page on my website where I want to prevent the same user from visiting it twice in a row. To prevent this, I plan to create a Lock object (from Python's threading library). However, I would need to store that across sessions. Is there anything I should watch out for when trying to store a Lock object in a session (s...