I'm using a Queue<T> for caching video. The idea is to fill it with data (Enqueue), start playing (Dequeue) and fill back continously as data arrives. Can I do the filling back part from a background thread?
...
Given a simple json document such as:
{ _id: 1234, messages: [...], otherfields: ... }
If two people open the document, and push a message onto the array, the first update will be clobbered by the second.
For types other than arrays, I'm ok with this.
In an rdbms this isn't an issue since the two messages are simply inserted into ...
Before your eyes glaze over at yet another ConcurrentModificationException question, this is not your typical ConcurrentModificationException question.
I understand ConcurrentModificationExceptions but I don't understand why I'm getting one in the following code. In the 'for' below, it appears that the iterator continues to live outsid...
I started using ZeroMQ this week, and when using the Request-Response pattern I am not sure how to have a worker safely "hang up" and close his socket without possibly dropping a message and causing the customer who sent that message to never get a response. Imagine a worker written in Python who looks something like this:
import zmq
c ...
First some background: In Java all the constructs for conditional waiting allows for spurious wakeups which can mess with fairness. I've been toying with writing an implementation for a ReadWrite lock which serves the incoming threads in strict order-of-arrival.
Now, my algorithm creates a new java.util.concurrent.Condition each time a ...
ASP.NET does not allow concurrent requests for the same session; meaning that a user can only make 1 request at a time.
For example, say we have Test1.aspx:
public partial class Test1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Session["test"] = 1;
System.Threading.Thread.Sleep(...
The Haskell wiki shows that you need to both set a compilation flag and a run-time flag to get multi-core support. Why isn't using the library enough to get the correct behavior at compile time? Why can't the run-time executable detect it was compiled with -threaded and use all cores on the system unless otherwise specified? I think turn...
Hello
I want to allow an xml document, that contains some configuration items, concurrent read-accesses (no write access) from several machines on a domain.
Could a simple DOMDocument30 be just what I need.
Or do you think FreeThreadedDOMDocument xml document template should be sufficient.
Or do you think of other xml document types ...
Hi;
class MyService {
public void a() {
synchronized(somekey) {
b();
}
}
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void b() {
...do DB works...
}
}
My aim is
1 - get the key
2 - start transaction
3 - commit transaction
4 - release the key
When i call a() method from outsid...
Possible Duplicate:
Peterson algorithm in Java?
I am trying to implement a lock in Java (lock interface) in the lines of petersen method. What is the simplest possible non-reentrant implementation to guarantee mutual exclusion.
flag[0] = 0;
flag[1] = 0;
turn;
P0: flag[0] = 1; P1: flag[1] = 1;
...
Dear Sirs,
I'm using EclEmma for coverage analysis.
My Java code includes a synchronized(MyClass.class) {} block.
EclEmma says it is only partially covered, event though I've got a unit test in which one thread gets access and another thread is blocked.
Is it possible to get full coverage of synchronized using EclEmma?
Can I annotat...
I have about 4 days to load 4 million rows of data, where the stored procedures appear to take about 500ms/row, so I am suggesting we temporarily repurpose two computers, one as the SQL Server and one to feed it. Each machine is a 4 cpu, 2 core/cpu computer with tons of memory.
There are two competing ideas on how to load the data.
o...
I was reading Robert Martin's Clean Code and in that he mentions about the code being highly cohesive:
Classes should have a small number of
instance variables. Each of the
methods of a class should manipulate
one or more of those variables. In
general the more variable a method
manipulates the more cohesive that
method ...
Looks like clojure will have a fork-join implementation which looks like a functional wrapper over java's fork join framework.
I am wondering what the difference between these and pmap/preduce could be ?
...
I'm wondering whether prepared statements in Android (instances of SQLiteStatement) are thread-safe. In particular I'm asking with regard to the following scenario:
In a ContentProvider you create a pre-compiled insert statement during onCreate. Then, in the overriden insert method you make use of this statement by binding a set of para...
I have been using Java's ConcurrentMap for a map that can be used from multiple threads. The putIfAbsent is a great method and is much easier to read/write than using standard map operations. I have some code that looks like this:
ConcurrentMap<String, Set<X>> map = new ConcurrentHashMap<String, Set<X>>();
// ...
map.putIfAbsent(name,...
I get an ever increasing(like 1,2,3,4,5,6,7...) task count when I print s.getTaskCount(). I don't understand why.
public class MyTask implements Runnable
{
public void run()
{
System.out.println("whatever....");
}
}
ScheduledThreadPoolExecutor s = new ScheduledThreadPoolExecutor(3);
s.scheduleAtFixedRate(new MyTas...
Going through the Goetz "Java Concurrency in Practice" book, he makes a case against using object pooling (section 11.4.7) - main arguments:
1) allocation in Java is faster than C's malloc
2) threads requesting objects from a pool require costly synchronization
My problem is not so much that allocation is slow, but that periodic garbag...
Hello SO!
Even though I've been in Java SE for quite some time now, I started EE & web w/ Java only about a month ago, so pardon if the question seems a bit noobish...
So here's the situation: I'm trying to write a JS based multi-player game with real-time interaction (let's say chess in this example, though it really doesn't matter wh...
This is entirely theoretical at this point, but I've been trying to wrap my
head around this problem. Let's take a client for an example. There are
forkIOd threads for every connection, and one of them wants to quit the
entire program (ie. /exit). How would this information be propagated to
other threads?
This is not a condition, but ...