concurrency

Concurrent moderating on a CMS

Hi, I'm building a custom CMS which allow user to post message to it. Messages are short and like tweets. The problem is that these message are moderated by real moderators. And there are multiple moderators working on the messages stream at the same time. And my concern is that what if these moderator are processing a same message. T...

Futures in Haskell

Does Haskell have an equivalent of Alice's ability to bind a variable to a future? val a = spawn foo; where foo is some function. I know Haskell supports channels and threads; I'm hoping for syntax as natural as Alice's to bind a value to a future and spawn a thread to calculate it without having to deal with the details. ...

concurrent programming in java

I have 2 threads running in paralel. The run function of the threads is as follows public void run(){ Runtime rt = Runtime.getRuntime(); Process s; try { s = rt.exec("cd /.../somefolder/"+i+"/"); closeStream(s); // this closes process s s = rt.exec("sh adapMs.sh"); closeStream(s); // this closes proc...

Do I need to call ThreadLocal.remove in the following case

Instead of writing the following non-thread safe method. private static final Calendar calendar = Calendar.getInstance(); public void fun() { // Going to call mutable methods in calendar. } I change it to a thread safe version. public void fun() { final Calendar calendar = Calendar.getInstance(); // Going to call mutabl...

Concurrent access to struct member

I'm using 32-bit microcontroller (STR91x). I'm concurrently accessing (from ISR and main loop) struct member of type enum. Access is limited to writing to that enum field in the ISR and checking in the main loop. Enum's underlying type is not larger than integer (32-bit). I would like to make sure that I'm not missing anything and I can...

Is my use of Timer and TimerTask creating a concurrency problem

Ive create a game and the portion of the program I am having a problem is modeled with a slightly modified MVC model. For the controller I use a TimerTask to run 60 times a second. Controller(){ timer = new Timer();// timer.schedule(tt,1000,1000/60); } TimerTask tt = new TimerTask() {//Controller member variable public void...

Is there a way to throttle the threads used by Task Parallel Library?

I'm using the TPL but I'm finding it tricky unit testing code that uses it. I'm trying to not introduce a wrapper over it as I feel it could introduce issues. I understand that you can set processor affinity in the TPL, but what'd be really nice is to set a thread maximum (probably per app-domain). Therefore, when setting the thread m...

ASP.NET Sessions and Concurrency

I have a legacy ASP.NET application in which there are some session/concurrency related issues and inconsistency. I am looking for the best way to do the re-design/ This is the scenario A. Multiple users can log on to the site and access/modify a Ticket's details. However, if a user is already in the process of altering the workflow......

Properly setting up a simple server-side cache

I'm trying to set up a server-side cache properly and I'm looking for constructive criticism on the setup I have currently. The cache is loaded when the Servlet starts and never changed again, so in effect it's a read-only cache. It obviously needs to stay in memory for the lifetime of the Servlet. Here's how I have it set-up privat...

Run multiple queries concurrently in SAS

I have 36 completely independent queries I need to run on a regular bases which would go much faster if they could run 3 at a time (the database cancels our queries if we try and do more than 3 at a time) instead of each one waiting for the previous to finish. I would like to do something like this /* Some prep code here*/ /* Launch b...

Java: Do all mutable variables need to be volatile when using locks?

Does the following variable, x, need to be volatile? Or does the manipulation within a utils.concurrent lock perform the same function as a synchronized block (ensuring it's written to memory, and not stored in cpu cache)? myMethod(){ myLock.lock(); x++; myLock.unlock(); } ...

More than one worker threads with same priority as IntentService?

So from what I've known, if I do an AsyncTask inside an Activity, the task may be killed when user quits the Activity before it is finished. One solution I've seen is using IntentService, which the system will try hard not to kill. My problem is that IntentService only uses one background thread to run all the tasks one by one. I have s...

Boost.Thread or just::thread ?

I am not yet a Boost user. I am however planning to go into it as soon as possible. However I am little concerned about Boost, and the likely future name collisions or differences with the forthcoming C++0x. (Maybe it is not a real issue, but for example I find the boost lambdas syntax pretty ugly, BOOST_FOREACH aggressive to the eye, an...

How to catch exceptions in FutureTask

After finding that FutureTask running in a Executors.newCachedThreadPool() on Java 1.6 (and from Eclipse) swallows exceptions in the Runnable.run() method, I've tried to come up with a way to catch these without adding throw/catch to all my Runnable implementations. The API suggests that overriding FutureTask.setException() should help ...

Managing multiple-processes: What are the common strategies?

While multithreading is faster in some cases, sometimes we just want to spawn multiple worker processes to do work. This has the benefits of not crashing the main app if one of the worker crashes, and that the user doesn't need to worry a lot about inter-locking stuffs. COM+'s Application Pooling seems like a good way to achieve this on...

How can I mix the Concurrency Runtime with .NET code?

I've been using the Concurrency Runtime in a C++ static library, and recently wanted to use this library in a C++/CLI project, to take advantage of the Windows Form designer and avoid MFC. Unfortunately, the Concurrency Runtime is not compatible with the /clr switch required in C++/CLI. I tried surrounding the included header files that ...

Software design problem

Hi all, I have an application which will be distributed to a large number of people within my company. I need to have some central data store for this application and dont have the budget for SQL server or anything like this. I noticed that there is a thing called a Local Database in VS2008... will this be suitable for a central data sto...

How do you manage concurrent access to forms?

We've got a set of forms in our web application that is managed by multiple staff members. The forms are common for all staff members. Right now, we've implemented a locking mechanism. But the issue is that there's no reliable way of knowing when a user has logged out of the system, so the form needs to be unlocked. I was wondering if th...

functional concurrency

Hi, when there is some list of advantages of functional languages, there is usually mentioned that it makes concurrency easier because there is not any variables which are subject of change. But, as my assembler-school-lessons-memory knows, there are registers in cpu and memory, that are both mutable. So when the high-level functional co...

why did I get IllegalThreadStateException after calling this.interrupt()?

try { this.interrupt(); } catch (IllegalThreadStateException e) { e.printStackTrace(); } I found out that an IllegalThreadStateException was thrown by putting print statement, no stack trace was printed. I have tried searching existing threads about Thread.interrupt() and IllegalThreadStateException, but didn't get much out of ...