Threads Section Index
What is the Fork/Join framework (JSR 166y)?
The fork/join framework in Java 7 allows developers to take advantage of multiple processors.
How can I determine if a thread is alive?
The thread class provides a method which can be called on an
instance of a Thread to determine if it is currently executing.
If isAlive() returns false the thread is either a new thread that is ...more
How do you write a Thread-Safe Singleton?
I have written plenty of non-thread-safe Singletons but it wasn't until recently when I tracked it down that I realized that thread-safety could be a big problem.
The problem is that in the typic...more
What is the use of start() function in starting a thread? Why we do not use the run() funtion directly to run the thread?
The start() method tells the Java Virtual Machine that it needs to create a system specific thread. After creating the system resource, it passes the Runnable object to it to execute its run() met...more
When returning from a wait(long), can I tell whether my object was signaled or the wait timed out?
There is a pretty standard way to check for this type of thing. You'll have to re-check your condition after the call to wait(timeout) returns:
public synchronized boolean acquire(long waitfor){
...more
How can I synchronize across two different classes?
The solution is to use a different monitor.
When you make a method synchronized, you are specifying that the currently running thread should obtain a monitor (lock) on the object which has the me...more
I am looking for a monitoring tool that will give me the status of the threads inside Weblogic?
I am looking for a monitoring tool that will give me the status of the threads inside Weblogic?
We are running Weblogic Server 5.1.0 service pack 8 on HPUX 11 servers in our production environment....more
If an object is referenced by a local variable -- is it safe from concurrency issues?
No. The local variable only holds a pointer to an object; if other threads can also point to this object, then it needs to be made thread-safe.
See also How do I ensure that my servlet is thread-...more
Is there some way to implement multi-tasking in Java (like "fork()" on UNIX)?
There isn't anything very portable, but (if you're willing to provide an implementation for each of your target platforms) you can either:
Have the host OS execute a new JVM (typically by calling...more
Where can I learn (more) about Java's support for transaction processing?
Check out the jGuru
Transactions FAQ.
Where can I learn (more) about Java on the Apple Mac platform?
Check out the jGuru Java on Mac FAQ.
Where can I learn (more) about Java on the Linux platform?
Check out the jGuru Linux FAQ.
Where can I learn (more) about the Java programming language syntax and semantics?
Check out the
jGuru JavaLanguage FAQ.
What is the purpose of the CopyOnWriteArrayList and CopyOnWriteArraySet collections?
Synchronized operations are costly and if you aren't modifying a collection much, it is best not to synchronize all collection accesses. The CopyOnWriteXXX collections avoid concurrent modificatio...more
What is the primary difference between pessimistic and optimistic concurrency control?
Pessimistic assumes conflicts will occur and avoids them through exclusive locks and explicit synchronization. With the optimistic approach, it is assumed conflicts won't occur, and they are dealt...more