concurrency

How to time-bound a computation in Java and be able to get all the results computed so far, even when the time budget ends (time-out)?

In a framework I'm developing the user can choose to run a certain time consuming task in background while doing something else. That task computes a series of results. In some point, when he/she needs the results from the background task, it's acceptable to wait some more time until: a) a time-out occurs (in this case the user would ...

how to login to multiple website accounts concurrently with Python

I am using urllib2 and HTTPCookieProcessor to login to a website. I want to login to multiple accounts concurrently and store the cookies to be reused later. Can you recommend an approach or library to achieve this? ...

ability to get the progress on a Future<T> object

With reference to the java.util.concurrent package and the Future interface I notice (unless I am mistaken) that the ability to start a lengthy tasks and be able to query on the progress only comes with the SwingWorker implementing class. This begs the following question: Is there a way, in a non-GUI, non-Swing application (imaging a c...

ASP.NET Parallel Web Service Calls

Hello, I have an aspx page which reads items from an SQL DB and displays them on a GridView. For every item located in DB there are several metadata associated with it which can be retrieved by making a Web Service call per item in the GridView. What I want to do is to make concurrent calls to the web-service (in order to save time from ...

What is the javac/java file system concurrency contract ?

I'm running a multi-threaded build with two dependant com.sun.tools.javac.Main.compile() invocations running on separate threads with ~10ms pause between them. Every now (every 100 builds or so), the second javac complains about bad class formats in the outputs from the first javac. This is on linux, but it has to work on all os'es. Wh...

Java: Synchronizing on primitives?

In our system, we have a method that will do some work when it's called with a certain ID: public void doWork(long id) { /* ... */ } Now, this work can be done concurrently for different IDs, but if the method is called with the same ID by 2 threads, one thread should block until it's finished. The simplest solution would be to have ...

Using JMS as a distributed lock manager?

I have a system where some loosely coupled components are communicating by exchanging messages over JMS. I am now looking at a new requirement which leads to some shared resource needing protection from access by two or more components at the same time (more or less an instance of the reader/write problem). I am looking for a way to coor...

Why does my Berkeley DB concurrent data store application hang?

My application hangs when trying to open a concurrent data store (CDB) database for reading: #0 0x0000003ad860b309 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0 #1 0x00007ffff7ce67de in __db_pthread_mutex_lock (env=0x610960, mutex=100) at /home/steve/ldm/package/src/Berkeley-DB/dist/../mutex/mut_pthread.c:318...

Intel Thread Building Blocks Concurrent Queue: Using pop() over pop_if_present()

What is the difference in using the blocking call pop() as compared to, while(pop_if_present(...)) Which should be preferred over the other? And why? I am looking for a deeper understanding of the tradeoff between polling yourself as in the case of while(pop_if_present(...)) with respect to letting the system doing it for you. This...

Dealing with two people buying a unique item in an online shop at the same time.

Hi there, I'm creating a simple online shop with PHP integrated with PayPal that sells unique items. What I'm wondering is how other shops deal with multiple people attempting to go through the payment process with the same item. This is my current draft strategy: Items have three status types: available, on hold & sold. As a user mo...

What concurrency works with the java file system ?

Using java IO, it seems like forking a new process gives better ability for a process B to read data written by process A to file than what you could get if thread A wrote to a file that thread B is trying to read (within the same process). It seems like the rules are not comparable to the memory model. So what file-based concurrency wo...

Example of 'volatile' preventing a compiler optimization in C#?

From what I understand, the 'volatile' modifier in C# has two effects: Inserts fences as necessary for the target processor Prevents certain compiler optimizations On x86 / amd64, (1) is irrelevant. Those processors don't require fences for volatile semantics. (ia64 is different, though.) So, we are down to (2). But, for examples th...

IllegalStateException while attempting to enter synchronized block

What does it mean when a IllegalStateException is thrown when entering a synchronized block? I'm seeing this sometimes inside the run-method of a thread: public void run() { while (true) { int n = 0; synchronized (service) { // IllegalStateException n = processPendingRequests(); ...

How can I improve garbage collector performance of .NET 4.0 in highly concurrent code?

I am using the task parallel library from .NET framework 4 (specifically Parallel.For and Parallel.ForEach) however I am getting extremely mediocre speed-ups when parallelizing some tasks which look like they should be easily parallelized on a dual-core machine. In profiling the system, it looks like there is a lot of thread synchroniz...

How to limit concurrency when using actors in Scala?

I'm coming from Java, where I'd submit Runnables to an ExecutorService backed by a thread pool. It's very clear in Java how to set limits to the size of the thread pool. I'm interested in using Scala actors, but I'm unclear on how to limit concurrency. Let's just say, hypothetically, that I'm creating a web service which accepts "jobs"...

Return values from Java Threads

I have a Java Thread like the following: public class MyThread extends Thread { MyService service; String id; public MyThread(String id) { this.id = node; } public void run() { User user = service.getUser(id) } } I have about 300 ids, and every couple of se...

Can I remove items from a ConcurrentDictionary from within an enumeration loop of that dictionary?

So for example: ConcurrentDictionary<string,Payload> itemCache = GetItems(); foreach(KeyValuePair<string,Payload> kvPair in itemCache) { if(TestItemExpiry(kvPair.Value)) { // Remove expired item. Payload removedItem; itemCache.TryRemove(kvPair.Key, out removedItem); } } Obviously with an ordinary Diction...

Concurrent access problem in mysql database

Hi i'm coding a python script that will create a number child processes that fetch and execute tasks from the database. The tasks are inserted on the database by a php website running on the same machine. What's the good (need this to be fast) way to select and update those tasks as "in progress" to avoid to be selected by multiple tim...

linq-to-sql user concurrency

I am currently working on a C# windows form with linq-to-sql that selects a row from a SQL table and then allows the user to edit the fields in that row. This form will be used by multiple users at a time and I would like to have it so when someone has selected a row and is currently entering data in the form (with which the row will be...

Running Emacs Remotely between several machines

I use Emacs remotely using X-Server in a Windows client and Linux server. I noticed that I can halt it using ctrl-z and then type fg 1 to get it working again. Is there some way that I could get it to halt on the machine that I am on, and then log into a different machine and start where I left off? When I start a new ssh session, the...