concurrency

Cache with timeout using .Net 4 & Concurrent Collections

How would you implement a cache class that supports timeouts using the new Concurrent Collections of .Net 4? The cache class will be typically holding hundreds of thousands of entries. A very large part of the cache may expire simultaneously. Unlike a typical web cache, which may shrink due to memory pressure, this class should only a...

Call to Java Object's wait() breaks thread synchronization

public class Main2 { public static void main(String[] args) { new Test2().start(); new Test2().start(); } } class Test2 extends Thread { @Override synchronized public void run() { try { System.out.println("begin wait"); wait(); } catch (Exception ex) { } ...

WCF. Overhead of ConcurrencyMode.Multiple

I have a WCF service which is used synchronously, but its ConcurrencyMode is set to ConcurrencyMode.Multiple value, because the service is stateless actually. How much overhead does this mode impose? Does it make sense to change the mode to ConcurrencyMode.Single? ...

Concurrency in Java EE application

Hi all, Previously I asked this question: http://stackoverflow.com/questions/2941657/read-quicktime-movie-from-servlet-in-a-webpage Basically I used a servlet to stream a movie file to a quicktime plugin on browser (In order to play file outside the root). At the end Ryan Fernandes asked me the question regarding concurrency issue. I ...

List of PID's in Erlang

Long story short I am trying to replicate the Sleeping barber problem in Erlang. In my solution I decided that for all the processes that are waiting I would put them into a list. Then, once it was that processes turn, I would take that PID off of the list. Unfortunately when I call length(myListOfPids). it fails, as an example: ...

java thread pool keep running

This is more a generic question than a specific one. I'm trying to have a multi threaded environment that stays active so that I can just submit tasks and run them. I want to do this without the hassle of executing in a web server or application server. The idea was to use a java thread pool for this, but the issue here is that the pool ...

How to compile and run C++0x with GCC/G++ in Eclipse CDT?

I am trying to figure out how to use the upcoming C++ release 0x. It should be available in GCC 4.3+ with using the gcc std=gnu++0x option. My simple thread program using 0x compiles in Eclipse CDT with std=gnu++0x added in Project > properties > C/C++ Build > Settings > Miscellaneous > Other flags. #include <iostream> #include <thread...

ThreadFactory usage in Java

Can someone briefly explain on HOW and WHEN to use a ThreadFactory? An example with and without using ThreadFactory might be really helpful to understand the differences. Thanks! ...

Visual presentation of threading versus message passing and actor models

I'm looking for a good slideshow/pdf/video explaining the differences in approach and thinking from hand-written threading of applications compared to the more abstracted and easier to use message passing and actor models. Does anyone know of existing resources to explain these concepts with good diagrams and visualizations? ...

Java mutex with smp

I am learning multi-thread programming; and whilst practising mutex, I notice that it seems doesn't work correctly on my dule-core laptop. The mutex code is at http://pastebin.com/axGY5y3c The result is as below: count value:t[0]1 count value:t[1]1 count value:t[2]2 count value:t[3]3 count value:t[4]4 The result shows that seemly t...

ConcurrentModificationException for ArrayList

I have the following piece of code: private String toString(List<DrugStrength> aDrugStrengthList) { StringBuilder str = new StringBuilder(); for (DrugStrength aDrugStrength : aDrugStrengthList) { if (!aDrugStrength.isValidDrugDescription()) { aDrugStrengthList.remove(aDrugStrength); } ...

Does Amazon S3 guarantee write ordering?

Amazon S3 provides an "eventual consistency" model, where data you store is eventually visible to all clients. I can't find any official information as to whether write ordering is guaranteed or not. This is fundamentally important if you are building an architecture where a client might want to read data right after someone else stored...

Concurrency during long running update in TSQL

Using Sql Server 2005. I have a long running update that may take about 60 seconds in our production environment. The update is not part of any explicit transactions nor has any sql hints. While the update is running, what's to be expected from other requests that occur on those rows that will be updated? There's about 6 million tota...

Is there a Scala-specific way to implement periodic execution?

AKA doing something at set intervals. For example, let's say I want to scan a certain directory every 60 seconds. In Java, I would use a ScheduledExecutorService like so: Executor pool = Executors.newScheduledThreadPool(10) pool.scheduleAtFixedRate(scanner, 0, 60, TimeUnit.SECONDS) and that works fine. The thing is, I'm thinking I'...

Different Concurrency Controls in ASP.NET

Zomg, so I am trying to pick up some concurrency stuff in asp.net, and so stumped. In .NET there's so many ways to go about it. I am overwhelmed with choices, so to speak. There's lock, Monitor, Mutex, and Semaphore, which all seem to specialize in different problems with subtle differences. Does anyone know of any good material I ca...

Windows Java File lock when referencing existing file in constructor?

Suppose I do the following in java for a process that stays open: import java.io.File; import java.util.Date; public class LogHolder { public static void main(String[] args) { File file1 = new File("myLogFile.log"); while (true) { System.out.println("Running " + new Date()); } } } Ha...

Critique my concurrent queue

This is a concurrent queue I wrote which I plan on using in a thread pool I'm writing. I'm wondering if there are any performance improvements I could make. atomic_counter is pasted below if you're curious! #ifndef NS_CONCURRENT_QUEUE_HPP_INCLUDED #define NS_CONCURRENT_QUEUE_HPP_INCLUDED #include <ns/atomic_counter.hpp> #include <boost...

dml by multiple users/commit scenarios in oracle

Hi, How does oracle treats dml statements executed by multiple users on the same data object?. Suppose, If there is a empty table named EMP(empname varchar2(30)) and user 'A' makes an entry into it using, insert into emp values('A'); but hasn't committed it yet. If another user 'B' logged into the same database commits, would he/sh...

What should happen when a deadlock is detected

Say I want to implement a database with a lock system, and I use lock avoidance and try to avoid a potential deadlock before acquiring it. My question is: When the session/transaction has already successfully acquired some resource A, and now it tries to acquire lock on resource B, when a deadlock is detected. Hence, the session fails...

Why does Java's scheduleWithFixedDelay work with a Runnable but not a FutureTask<?> wrapping a runnable?

Why does Java's scheduleWithFixedDelay work with a Runnable but not a FutureTask wrapping a runnable? This can be shown pretty easily with two different code samples: ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor(); executorService.scheduleWithFixedDelay(new FutureTask<Integer>(new Callab...