I have a cpu intensive code which uses a heavy dictionary as data (around 250M data). I have a multicore processor and want to utilize it so that i can run more than one task at a time. The dictionary is mostly read only and may be updated once a day.
How can i write this in python without duplicating the dictionary?
I understand that p...
I am struggling to explain "deadlock" in threads in easy words, so please help. What could be the best example of "deadlock" (say, in Java), and how it does happen in steps and how to prevent it? But without getting into details too deep. I know that's like asking two opposite things, but still. If you have any previous concurrent progra...
I am writing a web service in Java which needs to handle a large number of requests / second. The general flow will be:
Web service receives a request from client
Returns a 'keep polling me' response to client
Calls another web service (or
services), and waits for them to
respond (with a timeout)
Client polls our web service, until
it ...
Hi,
I am very much confused.
I have a transaction in ReadCommitted Isolation level. Among other things I am also updating a counter value in it, something similar to below:
Update tblCount set counter = counter + 1
My application is a desktop application and this transaction happens to occur quite frequently and concurrently. We re...
Does someone know of an open source BufferedIterator, where the next N elements are eagerly fetched on a background thread?
Here is an implementation from a TechRepublic article, but I assume it has not been thoroughly tested.
Iterators.buffer(Iterator toBuffer, int bufferSize) would be a nice addition to Guava, has that been considered...
I have a process which delegates asynch tasks to a pool of threads. I need to ensure that certain tasks are executed in order.
So for example
Tasks arrive in order
Tasks a1, b1, c1, d1 , e1, a2, a3, b2, f1
Tasks can be executed in any order except where there is a natural dependancy, so a1,a2,a3 must be processed in that order by ei...
In my destructor I want to destroy a thread cleanly.
My goal is to wait for a thread to finish executing and THEN destroy the thread.
The only thing I found about querying the state of a pthread is pthread_attr_setdetachstate but this only tells you if your thread is:
PTHREAD_CREATE_DETACHED
PTHREAD_CREATE_JOINABLE
Both of those h...
I like the ExecutorService series of classes/interfaces. I don't have to worry about threads; I take in an ExecutorService instance and use it to schedule tasks, and if I want to use an 8-thread or 16-thread pool, well, great, I don't have to worry about that at all, it just happens depending on how the ExecutorService is setup. Hurray!
...
I want to execute a read-only method on an object marked as const, but in order to do this thread-safely, I need to lock a readers-writer mutex:
const Value Object::list() const {
ScopedRead lock(children_);
...
}
But this breaks because the compiler complains about "children_" being const and such. I went up to the ScopedRead cla...
I've been reading Joe Duffy's book on Concurrent programming. I have kind of an academic question about lockless threading.
First: I know that lockless threading is fraught with peril (if you don't believe me, read the sections in the book about memory model)
Nevertheless, I have a question:
suppose I have an class with an int proper...
I have a clustered application that is suffering from database deadlocks.
It is a j2ee application using JPA and hibernate. The database is DB2 8.1 on Z/OS is set to page locking (this is a requirement for the company).
The problem is that the primary key are generated as a sequence, and will often deadlock while trying to insert reco...
I've got some code that submits a request to another thread which may or may not submit that request to yet another thread. That yields a return type of Future<Future<T>>. Is there some non-heinous way to immediately turn this into Future<T> that waits on the completion of the entire future chain?
I'm already using the Guava library t...
I'm midway through programming a Java program, and I'm at the stage where I'm debugging far more concurrency issues than I'd like to be dealing with.
I have to ask: how do you deal with concurrency issues when setting out your program mentally? In my case, it's for a relatively simple game, yet issues with threads keep popping up - any ...
I have trouble understanding this simple code:
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
Can anybody please explain me how it works (in simple terms because I am a newbie)? This short code is a part of this larger code.
To be more specific, I have the following q...
I've been going through the Java Concurrency in Practice book. It is definitively a great reference. I'm trying to extend the last example of the efficient and scalable result set cache to incorporate soft references. The objects stored in my cache can grow rather large and I need some way for those objects to get garbage collected wh...
I want to make almost 1000 inserts in a table in each second. And also each day I want to query all inserted rows just once at altogether. And I want to improve efficiency by multi-threading and connection-pooling. But i want to know which level of concurrency control is more suitable for me. The list of options for SQL-Server are in MSD...
Hi,
I'm currently responsible for putting up a multi environment BizTalk Deployment and we're planning on deploying two or more BizTalk Server in a BizTalk Group to provide High Availability and Scalability.
Our concern now is how to handle concurrency for adapters like WCF SQL and File Adapters because it is likely possible for exampl...
I have an implementation of java.util.Iterator which requires that the call to next() should always be proceeded by a call to hasNext(). (This is because results are returned asynchronosly in a multi threaded environment and it is never clear how many more results there might be).
Would it be 'correct' to properly document this in the J...
Over the weekend I realized that an application I'm working on which uses NHibernate as an ORM to a sqlite database has a concurrency issue.
I'm essentially looping through a collection in javascript and executing the following:
var item = new Item();
item.id = 1;
item.name = 2;
$.post("Item/Save", $.toJSON(item), function(data, testSt...
similar questions:
Pattern for wrapping an Asynchronous JavaScript function to make it synchronous
Wrapping an asynchronous method synchronously in C#
I have an object with a method I would like to expose to library clients (especially scripting clients) as something like:
interface MyNiceInterface
{
public Baz doSomethingAndBlo...