concurrency

What is the simplest way to lock an object in Django

I want to raise error when a user tries to delete an object when some other users are active in update_object view. I feel some sort of mutex-like locking mechanism is needed for that. Do you have any suggestions? ...

Sync (oswego) vs Lock (JDK5)

Just to be sure, can experts confirm that java.util.concurrent.locks.Lock and Doug Lea's original Sync are basically the same thing but with different names. acquire vs lock release vs unlock Thanks. ...

How to be guaranteed transactional integrity in SQL Server 2005

I have what looked to me at first glance a very simple problem. I want to be able to obtain a unique key value with a prefix. I have a table which contains 'Prefix' and 'Next_Value' columns. So you'd think you just start a transaction, get the next value from this table, increment the next value in the table and commit, concatenate the ...

Alternative for volatiles with cheapest performance hit

I want to implement the usual cooperative mechanism for canceling a thread. However the java memory model was only fixed in JDK5 while I'm in a pre-JDK5 environment. I understand, this means that doing something like this, as espoused in SCIP, will not be correct. class Worker implements Runnable { private volatile boolean _canceled...

How to pass parameters to a Thread object?

I'm working with a C++ class-library that provides a Thread base-class where the user has to implement a run() method. Is there a recommended way on how to pass parameters to that run() method? Right now I prefer to pass them via the constructor (as pointers). ...

Attach UncaughtExceptionHandler to a TimerTask

Hi Is it possible to attach an UncaughtExceptionHandler to a TimerTask? (Other than by calling Thread.setDefaultUncaughtExceptionHandler()) Cheers Rich ...

Should there be a limit to concurrent number of sessions for a web application?

What do you all think? ...

Mutex Stored Procedure

Hi All, I want to create some distributed mutual exclusion using a database table. It would be nice to have the following interface on a stored procedure: Wait(uniqueidentifier) I was originally thinking of implementing this by having a table of unique identifiers. A call to the procedure would wait until the unique identifier does no...

Using Object.wait(millisec) to simulate sleep

Here's a snippet of code that I saw in some code I'm maintaining. Object lock = new Object(); synchronized( lock ) { try { lock.wait( 50000 ); Thread.sleep( 3000 ); } catch(Exception ex) { } } The developer wants to suspend the current thread for some amount of time and is using Object#wait as the me...

C# Database Application Concurrency

Hi I wrote a multi user app in c# some time age using SQL Server 2005 express as back-end. I have a Orders collection. In order to use this class you would need to instantiate it and just call the Load(CustomerCode) method in order to populate the collection with the specified customers`s orders. My question: How do I enforce concurr...

Concurrent file write in Java on Windows

What happens when you concurrently open two (or more) FileOutputStreams on the same file? The Java API says this: Some platforms, in particular, allow a file to be opened for writing by only one FileOutputStream (or other file-writing object) at a time. I'm guessing Windows isn't such a platform, because I have two threads that re...

ASP.NET concurrency

Hi folks, I have an ASP.NET application that starts a long running operation during the Event Handler phase in the ASP.NET Page life cycle. This occurs when the end user pushes a button a bunch of queries are made to a database, a bunch of maps are generated, and then a movie is made from jpeg images of the maps. This process can take o...

What's the use of the SyncRoot pattern?

I'm reading a c# book that describes the SyncRoot pattern. It shows void doThis() { lock(this){ ... } } void doThat() { lock(this){ ... } } and compares to the SyncRoot pattern: object syncRoot = new object(); void doThis() { lock(syncRoot ){ ... } } void doThat() { lock(syncRoot){ ... } } However, I don't really...

Please confirm that this XMPP code is not threadsafe

I'm reading the source code to the Smack api and the the method XMPPConnection#disconnect looks like this: public void disconnect(Presence unavailablePresence) { // If not connected, ignore this request. if (packetReader == null || packetWriter == null) { return; } shutdown(unavailablePresence); if (roster ...

daemon threads in an app container

I read in a post to the Smack forum recently that Starting daemon threads in a Java EE server is a big no no Basically Smack's XMPPConnection starts one daemon thread to monitor incoming data & another to send outgoing data from/to the jabber server respectively. Is it reasonable to use daemon threads to listen for write/reads in ...

Is double-checked locking safe in Ruby?

This article states that double-checked locking is unsafe on certain language/hardware combinations when a shared variable can be updated with a reference to an object that is only partially initialized. I was wondering: does this also apply to Ruby? Is this something that varies by the Ruby implementation on the platform that it is ...

Haskell for simulating multilane traffic circle?

It was hard for me to come up with a real-world example for a concurrency: Imagine the above situation, where there are many lanes, many junctions and a great amount of cars. Besides, there is a human factor. The problem is a hard research area for traffic engineers. When I investigated it a some time ago, I noticed that man...

Can anyone recommend a concurrent, real-time diagramming/flowchart collaboration tool?

I'm looking to work with others to quickly build a rather large class flow diagram that may or may not be strict UML. Can anyone recommend a networked, concurrent collaboration tool for such a task? Price is not an issue, but the target system must be Windows. Surely someone must have done something like this in the past. Any ideas? ...

Understanding Goetz's article on Thread safety of HttpSession

Referring to Goetz's article, I want to refer to this piece of code HttpSession session = request.getSession(true); ShoppingCart cart = (ShoppingCart)session.getAttribute("shoppingCart"); if (cart == null) { cart = new ShoppingCart(...); session.setAttribute("shoppingCart", cart); } doSomethingWith(cart); From my avail...

Concurrency in a GIT repo on a network shared folder

Hello, I want to have a bare git repository stored on a (windows) network share. I use linux, and have the said network share mounted with CIFS. My coleague uses windows xp, and has the network share automounted (from ActiveDirectory, somehow) as a network drive. I wonder if I can use the repo from both computers, without concurrency p...