JAVA/CORBA CLASSES


NotesThread class
Example

The NotesThread class extends java.lang.Thread to include special initialization and termination code for Lotus Notes/Domino. This extension to Thread is required to run Java programs that make local calls to the Lotus Notes/Domino classes. It is not necessary for remote calls. An application that makes both local and remote calls can determine dynamically when to use the static methods sinitThread and stermThread. Remote calls can be made while a local thread is running; however, do not use an object obtained through one session in a call to the other session. Applets that do not start threads and agents that extend AppletBase and AgentBase do not need to code for local versus remote calls, as this capability is provided in the base code.

Executing threads through inheritance

To execute threads through inheritance, extend NotesThread instead of Thread and include a runNotes method instead of run:


Start a Domino thread in the same way as any other thread:
Executing threads through the Runnable interface

To execute threads through the Runnable interface, implement Runnable and include a run method as you would for any class using threads:


You might include both run and runNotes methods so that the class works whether you specify "implements Runnable" or "extends NotesThread":
Executing threads through the static methods

To execute threads through the static methods, call sinitThread() to initialize a thread and stermThread() to terminate the thread. Call stermThread() exactly one time for each call to sinitThread(); putting stermThread in a finally block is recommended.


Multithreading issues

You should avoid multithreading unless you have good reason to use it, such as proceeding while file input/output and Web requests are processing. Observe the following guidelines:


Specification of NotesThread

The specification of the class NotesThread is as follows:

public class NotesThread extends java.lang.Thread {
   public NotesThread();
   public NotesThread(Runnable t);
   public NotesThread(String name);
   public NotesThread(Runnable t, String name);
   public NotesThread(ThreadGroup group, String name);
   public NotesThread(ThreadGroup group, Runnable t, String name);
   public NotesThread(ThreadGroup group, Runnable t);
   public void initThread();
   public void termThread();
   public static void sinitThread();
   public static void stermThread();
   public final void run();
   public void runNotes() throws NotesException;
   public void finalize();
   public static void load(boolean debug) throws NotesException;
}

Example
See Also