Threading is a way to create transparent, extensible programs.
Thread.yield () is part of the thread scheduler (Java Threading Mechanism), a suggestion that the CPU can be transferred from one thread to another, stating: "I've done the most important part of the lifecycle, and it's time to switch to another task for a while."
You can then obtain a reference to the thread object that is driving the task by calling Thread,currentthread () inside the task. " 2. Generate return value from task
Runnable in a thread is a stand-alone task that performs work, and it does not return any values. If you want the task to return a value when it is finished, implement the callable interface instead of the Runnable interface.
Callable is a generic with a type parameter that represents the value returned from method call () instead of run (), and must be called using the Executorservice.submit () method.
3. Priority thread priority passes the importance of the thread to the scheduler. Although the order of the CPU to handle the existing set of threads is indeterminate, the scheduler will tend to allow higher priority threads to execute first. This does not mean that a thread with a lower priority does not get execution (priority does not cause a deadlock). Lower-priority threads are only performing less frequently. The priority is set at the beginning of run () and not set in the constructor. SetPriority (), getpriority (). When you adjust the priority, just use max_priority, norm_priority,min_priority. Thread
4. Background thread so-called background (daemon) thread, refers to the running of the program in the background to provide a common service thread. When all non-background threads end, the program terminates and kills all background threads in the process.
Use Xxxx.setdaemon (True) to set the thread as a background thread.