concurrency

Hashmap concurrency issue

I have a Hashmap that, for speed reasons, I would like to not require locking on. Will updating it and accessing it at the same time cause any issues, assuming I don't mind stale data? My accesses are gets, not iterating through it, and deletes are part of the updates. ...

Can Scala actors process multiple messages simultaneously?

The reply to a recent question of mine indicated that an actor processed its messages one at a time. Is this true? I see nothing that explicitly says that (in Programming in Scala), which contains the following snippet (pp. 593) If [the react method] finds a message that can be handled, [it] will schedule the handling of that message...

Processing concurrently in Scala

As in my own answer to my own question, I have the situation whereby I am processing a large number of events which arrive on a queue. Each event is handled in exactly the same manner and each even can be handled independently of all other events. My program takes advantage of the Scala concurrency framework and many of the processes i...

My datagrid's selection is lost when updating my database from the grid's bound dataset. Any workarounds?

I am using Xceed's Datagrid, bound to a dataset. I want to update the database when the datagrid's RowEditEnd is called. The problem is that in order to avoid concurrency violations when updating, I have to clear the dataset after update and refill it, like this: public void UpdateDatabaseFromDataSet() { adapter.Update(exampleDataSe...

Converse of java FileDescriptor .sync() for *reading* files

Reading the javadoc on FileDesciptor's .sync() method, it is apparent that sync() is primarily concerned with committing any modified buffers back to the underlying storage. I.e., making sure that anything that your program has output will actually make it to the disk (or socket or what-have-you, but my question pertains mainly to disks)...

Input on how to keep object map in sync between browser (javascript) and server (asp.net web service/database)?

I have a object map on my server (objects representing Customers, Orders, Items, related to each other, based on content from a database) and want to keep an up to date version of that object map in the browser where the user is manipulating and viewing the data. Since more users can access and modify the same object map at the same tim...

Apache HTTP Web Server Requests

Hi, When an http request is processed by the Apache web server it typically forks a new process unless one is using something like fastcgi. My question is related to "simultaneous requests" when using fastcgi. If I'm using fastcgi and I have a tree-like datastructure in main memory, do I need to worry about concurrent read/write acc...

Do I have to worry about InterruptedExceptions if I don't interrupt anything myself?

I'm using java.util.concurrent.Semaphore in a hobby project. It's used in a connection pool class I'm writing. I can use it with little fuss, except for this method: public void acquire(int permits) throws InterruptedException which forces me to handle the InterruptedException. Now, I'm not sure what "interrupting" a Thread even me...

Is it easy to write traditional concurrency problems in Erlang?

Hi, I have followed an operative system course where we learned usual concurrency problems as: the dinning philosophers problem, producer-consumer problem, readers & writers problem... Since their main purpose is to protect a shared variable, does it make sense to try to solve these problems in Erlang? Or maybe I just need more Erlang...

Why was the method java.lang.Thread.join() named like that?

Does anybody know why the method join() member of a java.lang.Thread was named like that? Its javadoc is: Waits for this thread to die. When join is called on some thread calling thread is waiting for the other to die and continue execution. Supposedly calling thread will die as well, but still it's not clear why the author used th...

Resonable number of threads for thread pool in Java

When creating an FixedThreadPool Executor object in Java you need to pass an argument describing the number of threads that the Executor can execute concurrently. I'm building a service class that's responsibility is to process a large collections of phone numbers. For each phone number I need to execute web service (that's my bottleneck...

Can Scala's Actor framework handle 10.000 actors without stack problems?

I want to do a multi-agent simulation containing about 10.000 agents (machine and product agents) using the Scala Actor framework. As I understand, if there are lots of actors passing messages around, can it run out of stack due the recursion? If so, how can I increase the stack sizes for the underlying worker threads? ...

Long running methods from Java SDK for testing purposes

I'm working through some tutorials and examples of java.util.concurrent package. Usually example authors put a placeholder marked with a comment 'long running task'. Since these examples are about concurrent programming I'm not keen of using Thread.sleep(long), surrounded by try-catch blocks. What do you use in these circumstances? To ...

Will using multiple threads with a RandomAccessFile help performance?

I am working on a (database-ish) project, where data is stored in a flat file. For reading/writing I'm using the RandomAccessFile class. Will I gain anything from multithreading, and giving each thread an instance each of RandomAccessFile, or will one thread/instance be just as fast? Is there any difference in reading/writing, as you can...

Good example of livelock?

I understand what livelock is but I was wondering if anyone had a good code-based example of it? And by code-based, I do NOT mean "two people trying to get past each other in a corridor". If I read that again, I'll lose my lunch. ...

How do I Invoke 3 REST endpoints in parallel ?

I have to invoke REST endpoints A, B & C in parallel and combine the resulting JSON from each into one JSON. All REST endpoints reside on different servers. My initial design calls for 3 Callables executed via FutureTasks. I will then do a Future.get(1000ms) on each FutureTask until they return a value. Is this how you would solve this ...

How to cache information in a DAO in a threadsafe manner

I often need to implement DAO's for some reference data that doesn't change very often. I sometimes cache this in collection field on the DAO - so that it is only loaded once and explicitly updated when required. However this brings in many concurrency issues - what if another thread attempts to access the data while it is loading or b...

How to provide for IPC API backward compatibility

I am designing a (SOAP-like) inter-process communication protocol for making function calls over a network. I want to make sure an older client can talk to a newer server. After thinking over it for a while, it seems like the only thing I can do are: avoiding API changes make it possible to add functions make it possible to add functio...

Are tasks parallelized when executed via an ExecutorCompletionService ?

I submitted 5 jobs to an ExecutorCompletionService, but it seems like the jobs are executed in sequence. The ExecutorService that is passed to the constructor of ExecutorCompletionService is created using newCacheThreadPool form. Am I doing anything wrong ? UPDATE Each job is basically doing a database query & some calculation. The code...

Concurrency vs Parallelism - What is the difference?

Concurrency vs Parallelism - What is the difference? Any examples ...