In the book Java Servlet Programming, there's an example servlet on page 54 which searches for primes in a background thread. Each time a client accesses the servlet, the most recently found prime number is returned.
The variable which is used to store the most recently found prime is declared as such:
long lastprime = 0;
Since this...
So, Ruby 1.9.1 is now declared stable. Rails is supposed to work with it and slowly gems are being ported to it.
It has native threads.... and a global interpreter lock.
Since a GIL is in place, do native threads offer any kind of benefit over green threads in 1.9.1?
...
In one of my recent answers, I gave a theoretical semaphore example of limiting access to memory resources:
public static byte[] createArray(int size) throws InterruptedException {
semaphore.acquire(size);
return new byte[size];
}
public static void releaseArray(byte[] array) {
semaphore.release(array.length);
}
I think th...
Is the standard MySQL JDBC driver thread-safe? Specifically I want to use a single connection across all threads, but each statement will only be used in a single thread. Are there certain scenarios that are safe and others that aren't? What's your experience here?
...
According to Brian Goetz's Java Concurrency in Practice JVM can't exit until all the (nondaemon) threads have terminated, so failing to shut down an Executor could prevent the JVM from exiting.
I.e. System.exit(0) doesn't necessarily work as expected if there are Executors around. It would seem necessary to put some kind of
public voi...
Hello Everybody,
I have the classic problem of a thread pushing events to the incoming queue of a second thread. Only this time, I am very interested about performance. What I want to achieve is:
I want concurrent access to the queue, the producer pushing, the receiver poping.
When the queue is empty, I wand the consumer to block to t...
I found an MSDN article that describes how EF handles concurrency when saving changes:
By default [...] Object Services saves object
changes to the database without
checking for concurrency. For
properties that might experience a
high degree of concurrency, we
recommend that the entity property be
defined in the conceptua...
I'm writing a Java program which uses a lot of CPU because of the nature of what it does. However, lots of it can run in parallel. When I run it, it only seems to use one CPU until it needs more then it uses another CPU - is there anything I can do in Java to force different threads to run on different cores/CPUs?
...
I have a Intel Quad Core CPU.
If I was to develop a Winforms application which only be used on my machine (I use C# btw), how many threads can I spawn?
Is there some sort of correlation between cores and the max number of threads I can have running at any one time? Would I need to find out how many threads are running at any one time a...
Hi,
How to use junit to run concurrency test?
Let's say I have a class
public class MessageBoard
{
public synchronized void postMessage(String message)
{
....
}
public void updateMessage(Long id, String message)
{
....
}
}
I wan to test multiple access to this postMessage concurrently.
Any advice ...
Hello
We have an strange problem with accessing to session variables concurrently. The microsoft documentation says that if two request are made for the same session (using the same sessionId), the second request execute only after the first request has finished. http://msdn.microsoft.com/en-us/library/ms178581.aspx
In our cases the be...
Do applet javascript calls serialize in any proper way? I'm considering implementing a model in which two threads send off javascript commands. One responds to requests from the browser (js), and the other hits the browser periodically. My question is this: what happens if these two javascript requests collide?
I'm worried about concurr...
I'm looking for a class where I can override a method to do the work, and return the results like an iterator. Something like this:
ParallelWorkIterator<Result> itr = new ParallelWorkIterator<Result>(trials,threads) {
public Result work() {
//do work here for a single trial...
return answer;
}
};
while (itr.hasNext()) {
...
In multi-thread environment, in order to have thread safe array element swapping, we will perform synchronized locking.
// a is char array.
synchronized(a) {
char tmp = a[1];
a[1] = a[0];
a[0] = tmp;
}
Is it possible that we can make use of the following API in the above situation, so that we can have a lock free array ele...
Hi all
I'm looking for a way to detect multiple usages of a piece of desktop software, without them necessarily being online at the time. An online solution could be to log the IP/MAC address and licence key on each start up and detect changes to the IP/MAC address.
But if the users of the software are on a local intranet that's not n...
So, I'm curious. How do you handle setting maximum execution time for threads? When running in a thread pool?
I have several techniques but, I'm never quite satisfied with them. So, I figure I'd ask the community how they go about it.
...
I am currently hunting a nasty bug in a multi-threaded environment using FutureTasks and Executors. The basic idea is this to have a fixed number of threads execute individual FutureTasks that compute a result that is to be displayed in a a table (never mind the GUI aspect here).
I have been looking at this for so long, I am beginning ...
I am interested in finding if producer-consumer problem when there are multiple produce and multiple consumer be solved without using assignment i.e., using functional style of programming? How?
Producer-consumer problem
Thanks
...
I've got a project that consists of two processes and I need to pass some data between them in a fast and efficent manner.
I'm aware that I could use sockets to do this using TCP, even though both processes will always exist on the same computer, however this does not seem to be a very efficient solution.
I see lots of information abou...
Hello *,
I am currently writing a scientific article, where I need to be very exact with citation. Can someone point me to either MSDN, MSDN article, some published article source or a book, where I can find performance comparison of Windows or .NET Synchronization primitives.
I know that these are in the descending performance order: ...