concurrency

Can I make Perl ithreads in Windows run concurrently?

I have a Perl script that I'm attempting to set up using Perl Threads (use threads). When I run simple tests everything works, but when I do my actual script (which has the threads running multiple SQL*Plus sessions), each SQL*Plus session runs in order (i.e., thread 1's sqlplus runs steps 1-5, then thread 2's sqlplus runs steps 6-11, e...

Concurrent Prime Generator

I'm going through the problems on projecteuler.net to learn how to program in Erlang, and I am having the hardest time creating a prime generator that can create all of the primes below 2 million, in less than a minute. Using the sequential style, I have already written three types of generators, including the Sieve of Eratosthenes, and ...

Distributed Concurrency Control

I've been working on this for a few days now, and I've found several solutions but none of them incredibly simple or lightweight. The problem is basically this: We have a cluster of 10 machines, each of which is running the same software on a multithreaded ESB platform. I can deal with concurrency issues between threads on the same mac...

How to choose the max thread count for an HTTP servlet container?

I'm developing a restful Web service that runs as a servlet (using blocking IO) in Jetty. Figuring out the optimal setting for max threads seems hard. Is there a researched formula for deciding the max number of threads from some easily measurable characteristics of the rest of the setup? ...

Is it safe to get values from a java.util.HashMap from multiple threads (no modification)?

There is a case where a map will be constructed, and once it is initialized, it will never be modified again. It will however, be accessed (via get(key) only) from multiple threads. Is it safe to use a java.util.HashMap in this way? (Currently, I'm happily using a java.util.concurrent.ConcurrentHashMap, and have no measured need to im...

Locking in C#

I'm still a little unclear and when to wrap a lock around some code. My general rule-of-thumb is to wrap an operation in a lock when it reads or writes to a static variable. But when a static variable is ONLY read (e.g. it's a readonly that is set during type initialization), accessing it doesn't need to be wrapped in a lock statement, ...

What's the best way to pass data between concurrent threads in .NET?

I have two threads, one needs to poll a bunch of separate static resources looking for updates. The other one needs to get the data and store it in the database. How can thread 1 tell thread 2 that there is something to process? ...

Wait until any of Future<T> is done

I have few asynchronous tasks running and I need to wait until at least one of them is finished (in the future probably I'll need to wait util M out of N tasks are finished). Currently they are presented as Future, so I need something like /** * Blocks current thread until one of specified futures is done and returns it. */ public st...

Multi-Core and Concurrency - Languages, Libraries and Development Techniques

The CPU architecture landscape has changed, multiple cores is a trend that will change how we have to develop software. I've done multi-threaded development in C, C++ and Java, I've done multi-process development using various IPC mechanisms. Traditional approaches to using threads doesn't seem to make it easy, for the developer, to ut...

How to implement simple threading in Java

I'm looking for the simplest, most straightforward way to implement the following: The main program instantiates worker threads to do a task. Only n tasks can be running at once. When n is reached, no more workers are started until the count of running threads drops back below n. ...

What are the current state of affairs on threading, concurrency and forked processes, in Ruby on Rails?

Ruby on Rails does not do multithreaded request-responses very well, or at least, ActiveRecord doesn't. The notion of only one request-response active at the same time can be a hassle when creating web applications which fork off a shell-command that takes long to finish. What I'd like are some of your views on these kinds of setups? I...

Which programming language makes concurrent programming as easy as possible?

If you want to create programs with threads/processes that run parallel you have to learn about many stuff, like race conditions, locks, semaphors, monitors, deadlocks .... Is there a language that makes creation of parallel programs as easy as object-oriented programming languages help creating complex architectures? Or which programmi...

MS Access Data Access Limitations

I have a project right now where I'd like to be able to pull rows out of an Access database that a 3rd party product uses to store its information. There will likely be a small number of users hitting this database at the same time my "export" process does, so I'm a little concerned about data integrity and concurrent access. Will I li...

How does cherrypy handle user threads?

I'm working on a django app right and I'm using cherrypy as the server. Cherrypy creates a new thread for every page view. I'd like to be able to access all of these threads (threads responsible for talking to django) from within any of them. More specifically I'd like to be able to access the thread_data for each of these threads from w...

The difference between the Runnable and Callable interfaces in Java

What is the difference between using the Runnable and Callable interfaces when designing a concurrent thread in Java, why would you choose one over the other? ...

When ThreadPool.QueueUserWorkItem returns false

The MSDN states that the method returns true if the method is successfully queued; NotSupportedException is thrown if the work item is not queued. For testing purposes how to get the method to return false? Or it is just a "suboptimal" class design? ...

Asynchronous WPF Commands

Note: The code in this question is part of deSleeper if you want the full source. One of the things I wanted out of commands was a baked design for asynchronous operations. I wanted the button pressed to disable while the command was executing, and come back when complete. I wanted the actual work to be performed in a ThreadPool work ...

Java 1.4 synchronization

I have a class proposing translations utilities. The translations themselves should be reloaded every 30 minutes. I use Spring Timer support for that. Basically, my class looks like : public interface Translator { public void loadTranslations(); public String getTranslation(String key); } loadTranslations() can be pretty long ...

Dataflow Programming API for Java?

I am looking for a Dataflow / Concurrent Programming API for Java. I know there's DataRush, but it's not free. What I'm interested in specifically is multicore data processing, and not distributed, which rules out MapReduce or Hadoop. Any thoughts? Thanks, Rollo ...

What tools/diagrams do you use for modelling multithreaded systems?

I'm sitting there every time I model my systems, thinking, there must be a better way to model concurrency than using UML activity diagrams. Please share your thoughts. What's your favourite tool or format for modelling and getting a clear understanding of how to build a concurrent system? ...