Display. getdefault (): This method returns the display instance in the user GUI thread, regardless of whether the current thread is a user GUI thread,
If this instance does not exist, a display instance in the GUI thread is created by default.
Java code
/**
* Returns the default display. One is created (making the thread that
* Invokes this method its user-interface thread) if it did not already
* Exist.
*
* @ Return the default display
*/
Public static display getdefault ()
{
Synchronized (device. Class)
{
If (default = NULL)
Default = New Display ();
Return default;
}
}
Display. getcurrent (): return the display instance in the current thread. If this is a graphical interface thread, the instance is not empty. If the current thread is not a graphical interface thread, the instance is empty.
You can determine whether the current thread is an interface thread based on whether the display instance returned by display. getcurrent () is null. If it is not null, it is an interface thread; otherwise, it is a background thread.
Java code
/**
* Returns the display which the currently running thread is
* User-interface thread for, or null if the currently running thread is not
* A user-interface thread for any display.
*
* @ Return the current display
*/
Public static display getcurrent ()
{
Return finddisplay (thread. currentthread ());
}
In the subsequent articles, we will particularly describe the interface thread and background thread in SWT.