Updating the JavaFx Gui with threads and or Tasks

I am creating a chat program that contains a GUI that I have created in the new version of the JavaFx Scene builder. I have a main method that extends application and i have a simpleController (that …

why using volatile with synchronized block?

I saw some examples in java where they do synchronization on a block of code to change some variable while that variable was declared volatile originally .. I saw that in an example of singleton class …

Eclipse (Helios) debugger – getting different Results in Debug mode and Run mode

I am debugging RCP( multi-threaded GUI application) using Eclipse Helios. When I am executing the same method, I get a null pointer exception in run mode, but in debug mode, I don’t get any …

Thread Safe Singletons in Java

The wikipedia article on Singletons mentions a few thread safe ways to implement the structure in Java. For my questions, let’s consider Singletons that have lengthy initialization procedures and are …

“Java DateFormat is not threadsafe” what does this leads to?

Everybody cautions regarding Java DateFormat not being thread safe and I understand the concept theoretically. But I’m not able to visualize what actual issues we can face due to this. Say, I’ve a …

What is the difference between Thread.start() and Thread.run()?

Why do we call the start() method, which in turn calls the run() method? Can’t we directly make a call to run()? Please give an example where there is a difference.

Java long running task Thread interrupt vs cancel flag

I have a long running task, something like: public void myCancellableTask() { while ( someCondition ) { checkIfCancelRequested(); doSomeWork(); } } The task can be cancelled (…

Impossible to make a cached thread pool with a size limit?

It seems to be impossible to make a cached thread pool with a limit to the number of threads that it can create. Here is how static Executors.newCachedThreadPool is implemented in the standard Java …

Executors.newCachedThreadPool() versus Executors.newFixedThreadPool()

newCachedThreadPool() versus newFixedThreadPool() When should I use one or the other? Which strategy is better in terms of resource utilization?

Performance of ThreadLocal variable

How much is read from ThreadLocal variable slower than from regular field? More concretely is simple object creation faster or slower than access to ThreadLocal variable? I assume that it is fast …