All Questions

638
votes
17answers
374877 views

What is a race condition?

When writing multi-threaded applications, one of the most common problems experienced are race conditions. My questions to the community are: What is a race condition? How do you detect them? How ...
521
votes
13answers
99682 views

Is JavaScript guaranteed to be single-threaded?

JavaScript is known to be single-threaded in all modern browser implementations, but is that specified in any standard or is it just by tradition? Is it totally safe to assume that JavaScript is alway...
635
votes
11answers
398112 views

Collection was modified; enumeration operation may not execute

I can't get to the bottom of this error, because when the debugger is attached, it does not seem to occur. Below is the code. This is a WCF server in a Windows service. The method NotifySubscribers i...
447
votes
19answers
178899 views

Do you ever use the volatile keyword in Java?

At work today, I came across the volatile keyword in Java. Not being very familiar with it, I found this explanation: Java theory and practice: Managing volatility Given the detail in which tha...
316
votes
5answers
82416 views

What is a good pattern for using a Global Mutex in C#?

The Mutex class is very misunderstood, and Global mutexes even more so. What is good, safe pattern to use when creating Global mutexes? One that will work Regardless of the locale my machine is in...
157
votes
15answers
129037 views

What's the difference between Thread start() and Runnable run()

Say we have these two Runnables: class R1 implements Runnable { public void run() { … } … } class R2 implements Runnable { public void run() { … } … } Then what's the diffe...
62
votes
7answers
26229 views

Only inserting a row if it's not already there

I had always used something similar to the following to achieve it: INSERT INTO TheTable SELECT @primaryKey, @value1, @value2 WHERE NOT EXISTS (SELECT NULL FROM ...
4
votes
1answers
4576 views

Random errors when changing series using JFreeChart

I'm making a GUI that display result of background calculations. But before that, I wanted to test changing the dataset. Here is my code: DefaultXYDataset dataset = new DefaultXYDataset(); @Override...
287
votes
19answers
233898 views

How to wait for all threads to finish, using ExecutorService?

I need to execute some amount of tasks 4 at a time, something like this: ExecutorService taskExecutor = Executors.newFixedThreadPool(4); while(...) { taskExecutor.execute(new MyTask()); } //...wa...
344
votes
22answers
252916 views

Is there an advantage to use a Synchronized Method instead of a Synchronized Block?

Can any one tell me the advantage of synchronized method over synchronized block with an example?

Previous Next