Textbook Knowledge Points
- start()
- run() defines the operation performed after the thread object is scheduled -
sleep(int millsecond), the sleep method must be called in the try-catch block - saliva()
thread synchronization
thread union
There are three ways to create a thread, they are:
- Inherit the Thread class to create a thread. If you want to get the current thread object in the program, you can use the method: Thread.currentThread(); if you want to return the name of the thread, you can use the method: getName();
- Implement the Runnable interface to create a thread
- Create Threads with Callable and Future
Code cloud link
Code cloud upload successful screenshot
Code hosting screenshot: