concurrency

multithreading loop effecient?right?

I have the following multithreading function to implement threads fetching from a list of urls to parse content. The code was suggested by a user and I just want to know if this is an efficient way of implementing what I need to do. I am running the code now and getting errors on all functions that worked fine doing single thread. for ex...

Any good implementation of Actors for C#?

Is there any good implementation of actors concurrency model for .net/c#? I have to optimize a c# routine and i think that actors model fits perfectly as a solution for my problem. Unfortunately i have experience only with scala implementation. ...

C# multithread concurrency mechanism to wait on a given result

Hi there, I need a mechanism to implement the following scenario: two or more threads need to load a given set of values at the same time only one request must be done per value, so if two threads need to load the same subsets, one must wait for the other I don't want to have a lock (or mutex, or another primitive) on each value since...

fluent nhibernate automap version column

Current code in my convention: public void Apply(FluentNHibernate.Conventions.Instances.IVersionInstance instance) { instance.Column("RowVersion"); instance.Not.Nullable(); instance.UnsavedValue("0"); instance.Default(1); } This doesn't render the RowVersion as a version column. It treats Ro...

Handle version conflict when multiple concurrent editor on the same model rails

how to Handle version conflict when multiple concurrent editor on the same model rails? for example user A click edit on the post controller and start editing the content user B click edit on the post controller and start editing the title user B is done and click save user A is done and click save and override the modifications done by...

Concurrent Processing in Scala

Hello: I am trying use Concurrent programming in Scala. Based in this example here in StackOverflow, I made a program based on Problem 1 of Project Euler. I try three methods: The first one is a simple execution, with no paralelism. The second uses java.util.concurrency API through Executors and Callables. The third, based on page men...

Are there any java collection wrappers/collections that fail upon multithreaded access ?

I'm trying to track some concurrency problems related to collections in a large code-base. I would like to replace all the collections/maps with an alternate implementation that throws an exception when the 3rd thread accesses it (or similar; I can see several possible strategis that might work). Anyone know of any libraries/tools/strat...

Java volatile variable question

Reading this DZone article about Java concurrency I was wondering if the following code: private volatile List list; private final Lock lock = new ReentrantLock(); public void update(List newList) { ImmutableList l = new ImmutableList().addAll(newList); lock.lock(); list = l; lock.unlock(); ...

Unlocking a lock from a thread which doesn't own it, or redesigning to avoid this?

I have an archive object which manages various byte arrays and hands out InputStreams and OutputStreams for reading and writing them. Each byte array has an associated ReentrantReadWriteLock. The constructor of the subclass of InputStream which the archive produces acquires the lock for the relevant data, while close() releases the loc...

Java Concurrency - Web Application

Hi all, I think I found more bugs in my web application. Normally, I do not worry about concurrency issues, but when you get a ConcurrentModificationException, you begin to rethink your design. I am using JBoss Seam in conjuction with Hibernate and EHCache on Jetty. Right now, it is a single application server with multiple cores. I...

Strange behavior: Scala Actors 2.7.7 vs. 2.8-Snapshot

I'm an 18 years old trainee and I'm discovering scala which I like very much :-). To get familiar with the scala actors I wrote a small simulation with some gears and one controller. The ActorApplication creates N gears with random speed. The controller calculates a synchronization speed and starts the gear-actors. The gears synchronize ...

What are Concurrency Conflicts?

What are Concurrency Conflicts with regards to SQL database? Thanks ...

Java Concurrency: lock effiency

Hello My program has 100 threads. Every single thread does this: 1) if arrayList is empty, add element with certain properties to it 2) if arrayList is not empty, iterate through elements found in arrayList, if found suitable element (matching certain properties), get it and remove the arrayList The problem here is that while one th...

Using Postgres in a web app: "transaction aborted" errors

Hi, Recently I moved a web app I'm developing from MySQL to PostgreSQL for performance reasons (I need functionality PostGIS provides). Now quite often encounter the following error: current transaction is aborted, commands ignored until end of transaction block The server application uses mod_python. The error occurs in the hailing f...

How to properly do threading in C++?

I have a rather large, dynamic sparse matrix object class to write, and I want to make the following happen: one thread to handle placing elements into the matrix, and one to handle reading from the matrix. The only time when these two would conflict would be when they would both want to access the same row/column at the same time. As ...

WaitForSingleObject gets his semaphore in XP but not in Vista

The following code runs perfectly well on my XP SP2 machine, but the call to WaitForSingleObject waits indefinitely when running on my Vista machine: HANDLE ghSemaphore; ghSemaphore = CreateSemaphore(NULL, 0, 1, "COM_PHILOERTEL_FINA"); if (ghSemaphore == NULL) { MessageBoxA(NULL,"Error creating semaphore","ERROR",0); return FALSE; } ...

Which amount of code execution should I parallelize?

If I want to parallelize the execution of an algorithm what are the smalls chunks of code that I should split? A classic example is a sorting algorithm. For what element size or typical execution time does it make sense to split the sorting between multiple threads? Or when is the overhead for waiting on another thread larger than the e...

Is F# really faster than Erlang at spawning and killing processes?

Updated: This question contains an error which makes the benchmark meaningless. I will attempt a better benchmark comparing F# and Erlang's basic concurrency functionality and inquire about the results in another question. I am trying do understand the performance characteristics of Erlang and F#. I find Erlang's concurrency model ve...

How should one handle a javax.persistence.OptimisticLockException ?

I'm new to JPA so forgive me if not being clear. Basically I want to prevent concurrent modifications by using Optimistic Locking. I've added the @Version attribute to my entity class. I need to know if this algorithm on handling OptimisticLockException is sound. I'm going to use the Execute Around Idiom like so: interface UpdateUnitO...

concurrent mySql database queries

Hi I'm running mySql server that being updated every 4 hours. In the mean while data can be retrieved. Does mySql handle this scenario where the DB is being updated and a query from the user is received? or I should handle this scenario? Is it possible to create a snapshot of the DB just before the update takes place and query this D...