Given a multi-threaded application, yield will cause the current executable thread to pause execution and be set to standby. Then, the JVM will start starting another thread that was previously pending.
I believe that the same stream that has just lost may be officially planned for a start.
And I have yet to see it in the wild. Therefore, I think it is safe.
Develop:
In a multi-threaded environment, threads are scheduled and unplanned and run in the JVM. Thus, even if the income is not called in the code, your thread may / will automatically be inferior to other threads when the JVM decides that it is necessary. This allows you to work with multiple threads in a single core processing environment.
The calling income simply tells the JVM to put the current thread on hold, even if the JVM is not going to.
I will try to illustrate:
The following is a very simplified illustration of the execution of 2 threads over time (suppose 1 core) -
Thread\Time 1 2 3 4 5 6 7 8 9 Thread 1 ----------- ----- ------- Thread 2 ------- ---------- ------
Whenever you see a '-' , this means that the thread is executing. A ' ' means the thread is waiting. As you can see, only 1 thread can actually start at a time. So, while 1 is working, another is waiting. What needs to be done is to give other threads the opportunity to run ahead of the current current thread.
jjnguy
source share