Browse DevX
Sign up for e-mail newsletters from DevX

Search the Tips

Threading - Page 2

21-40 of 64     Previous     Next
Identify Atomic and Non-Atomic Operations
by C.V. Ram
In Java, the reading and writing of 32-bit or smaller quantities are guaranteed to be atomic. By atomic we mean each action takes place in one step and cannot be interrupted. Thus, when we have ...
Re-entrant Functions
by Danny Kalev
A function that can be safely called while it's already executing is said to be re-entrant. The C++ standard doesn't state whether the Standard Library's functions are re-entrant; this is an ...
System Shutdown
by DevX Pro
Is there an API that I can use to sense that the system is shutting down?
Stopping Threads
by DevX Pro
How do you stop a Thread without using the stop() method?
Designing Applications for Symmetric Multiprocessing Environments
by Danny Kalev
Many modern operating systems support Symmetric Multiprocessing (SMP)—a hardware architecture that uses two or more processors on one machine and enables you to achieve true multitasking. On ...
Accessing an Object From Another Process
by Danny Kalev
On modern operating systems, a process consists of an executable file that the OS loads into the system's memory and executes. A process normally has an entry point and one or more exit points. The ...
AWT Thread Interaction
by DevX Pro
I have two threads in an application. Thread A displays a form and allows the user to interact with it, thread B executes a loop which continually retrieves data and updates the form object by executing a synchronized method in the form object. I first tried to code thread A to use the showDialog() method on the form object, then started thread a and then thread b. However, thread a starts and the form then waits to be closed before the statement starting thread b is executed. I then tried just using the show() method in thread a - this allows the start of thread b to execute but I lose my interaction with the form.
Volatile Semantics and Container Objects
by Danny Kalev
Volatile objects are used in multithreaded applications and applications that map hardware devices into registers. Although you can declare an STL container object with the volatile qualifier, you ...
Multithreading Misconceptions
by Danny Kalev
Force an Object to Destroy Itself
by Danny Kalev
Sometimes, you need to force an object to destroy itself because its destructor performs an operation needed immediately. For example, when you want to release a mutex or close a ...
Get all your Threads and Thread Groups
by Behrouz Fallahi
It might be useful to garner an enumeration of all thread groups and ...
Useful Thread Terminology
by Behrouz Fallahi
Java makes working with threads relatively straight forward. However, there are situations, or anomalies that can arise due to improper design of a thread-based code. The following provides you with ...
Conditional Semaphores
by DevX Pro
I am trying to create a queue that will be emptied by multiple threads simultaneously. In C/C++ this requires the use of a conditional semaphore to signal that the queue is empty/not empty. How can a Condition be implemented in Java?
Create Timer Threads Using the Swing Timer Class
by Ajit Sagar
The Swing package, which is now a standard API package in Java 2, offers a new timer utility. This utility is implicitly threaded and lets you create as many timer threads as required, while ...
Create a Timer Using the Static Sleep() Method
by Ajit Sagar
The simplest way to create a timer in Java is to use the static sleep() method on the Thread class. This code shows a main class that has a while loop for implementing the timer. The argument read ...
Get a Free Grip on the Output of the Process Object
by Behrouz Fallahi
There are times when you have to use the exec(...) method of java.lang.Runtime class to launch a program. For ...
Optimize Your Scripts in DHTML When Accessing a Collection
by Jai Bardhan
A typical operation in DHTML is to iterate through a collection of objects. Let's say you're writing an HTML application that indexes content. Your task is to collect all the H1 elements on a ...
Running Piped Threads
by Ajit Sagar
Each piped thread has a run() method, and in an application using piped streams, their run() methods are interdependent. These code excerpts illustrate the run() methods for a PipedInputStream ("in_") and a PipedOutputStream ("out_").
Threading Piped Streams
by Ajit Sagar
Though piped streams are typically used in separate threads, you can use this class to connect them together.
Using Piped Streams in an Application
by Ajit Sagar
Learn how to create and use the PipedInputStream and PipedOutputStream objects in separate classes and in separate threads.
21-40 of 64     Previous     Next
Thanks for your registration, follow us on our social networks to keep up-to-date