Hi
The java meomry model mandates that synchronize blocks that synchronize on the same monitor enforce a before-after-realtion on the variables modified within those blocks. Example:
// in thread A
synchronized( lock )
{
x = true;
}
// in thread B
synchronized( lock )
{
System.out.println( x );
}
In this case it is garanteed tha...
I have the following Java code:
final Future future = exeService.submit(
new Runnable() {
public void run() {
myObject.doSomething();
}
}
);
future.get();
where exeService is an instance of
java.util.concurrent.ExecutorService
The problem is that myObject.doSomething() never returns, and, hence...
Let's say i have a Domain Model that im trying to make compatible with multithreading.
The prototype domain is a game domain that consists of Space, SpaceObject, and Location objects.
A SpaceObject has the Move method and Asteroid and Ship extend this object with specific properties for the object (Ship has a name and Asteroid has a colo...
I have scheduled a CRON job to run every 4 hours which needs to gather user accounts information.
Now I want to speed things up and to split the work between several processes and to use one process to update the MySQL DB with the retrieved data from other processes.
In JAVA I know that there is a thread pool which I can dedicate some t...
Hi,
UserA and UserB are changing objectA.filedA objectA.filedB respectively and at the same time.
Because they are not changing the same field one might think that there are no overlaps.
Is that true?
or the implementation of pm.makePersistnace() actually override the whole object...
good to know...
...
Hi,
I have a program that starts up and creates an in-memory data model and then creates a (command-line-specified) number of threads to run several string checking algorithms against an input set and that data model. The work is divided amongst the threads along the input set of strings, and then each thread iterates the same in-memor...
I'm trying to figure out the best way to use agents to consume items from a Message Queue (Amazon SQS). Right now I have a function (process-queue-item) that grabs an items from the queue, and processes it.
I want to process these items concurrently, but I can't wrap my head around how to control the agents. Basically I want to keep a...
My User object that I want to create and store in the datastore has an email, and a username. How do I make sure when creating my User object that another User object doesn't also have either the same email or the same username?
If I just do a query to see if any other users have already used the username or the email, then there could...
Dictionary<Image, ManualResetEvent> waitHandleMap = new Dictionary<Image, ManualResetEvent>();
List<Image> images = GetImagesWhichAreAlreadyInVisualTree();
foreach (var image in images)
{
image.Source = new BitmapImage(new Uri("some_valid_image_url"));
waitHandleMap.Add(image, new ManualResetEvent(false));
image.ImageOpened +...
Is it safe to assume that
java.util.concurrent.CompletionService.take().isDone()
will always return true? If so, why does take() return a Future, rather than the value directly? If not, what does "completed task" as used in the documentation mean?
...
I am working on a tutorial for my Java concurrency course. The objective is to use thread pools to compute prime numbers in parallel.
The design is based on the Sieve of Eratosthenes. It has an array of n bools, where n is the largest integer you are checking, and each element in the array represents one integer. True is prime, false is...
I decided to learn concurrency and wanted to find out in how many ways instructions from two different processes could overlap. The code for both processes is just a 10 iteration loop with 3 instructions performed in each iteration. I figured out the problem consisted of leaving X instructions fixed at a point and then fit the other X in...
I am reading "Java Concurrency in practice" and looking at the example code on page 51.
This states that if a thread has references to a shared object then other threads may be able to access that object before the constructor has finished executing.
I have tried to put this into practice and so I wrote this code thinking that if I ra...
Hello,
I started dealing with NSOperations and (as usual with concurrency) I'm observing strange behaviour.
In my class I've got an instance variable:
NSMutableArray *postResultsArray;
when one button in the UI is pressed I initialize the array:
postResultsArray = [NSMutableArray array];
and setup the operations (together with...
I am writing a C# application and I would like to make calls to different matlab functions simultaneously(from different threads). Each Matlab function is located in its own compiled .net library. It seems that I am only able to call one Matlab function at a time however.
ie, if matlab_func1() gets called from thread1 then matlab_func2...
Is there any way to implement Erlang-style light-weight processes in .NET?
I found some projects that implement Erlang messaging model (actors model). For example, Axum. But I found nothing about light-weight processes implementation. I mean multiple processes that run in a context of a single OS-thread or OS-process.
...
I am reading "Java Concurrency in practice" and looking at the example code on page 51.
According to the book this piece of code is at risk of of failure if it has not been published properly. Because I like to code examples and break them to prove how they work. I have tried to make it throw an AssertionError but have failed. (Leading ...
I am creating a web application that is accessing a SQLite database in the server. I also have "clients" that updates this same database. As we know SQLite locks the entire database during INSERTs which are done by the clients and the web application is also trying to make some UPDATEs at the same time. So my problem now is about concurr...
I remember an example where reads in a transaction then writing back the data is not safe because another transaction may read/write to it in the time between. So i would like to check the date and prevent the row from being modified or read until my transaction is finish. Would this do the trick? and are there any sql variants that this...
I cant believe this, i always throught the below would be concurrency safe.
I write to a row in one transaction and i am able to read the dirty value from another transaction/command/connection! Why is this possible (not my main question) isnt this not desired and cause more troubles!?!
Anyways, i expected that once i write to a row no...