Thread, yield yields a CPU dispatch

Source: Internet
Author: User

 Public classYield01extendsThread { Public Static voidMain (string[] args) {NewYield01 (). Start ();  for(inti = 0; i < 1000; i++) {            if(i%5==0) {Thread.yield (); } System.out.println (I+ ": @[email protected]"); }} @Override Public voidrun () { for(inti = 0; i < 1000; i++) {            if(i%5==0) {Thread.yield (); } System.out.println (I+ ": Yield"); }    }}

Results:
(Note that this is not an alternate execution.) It's just like this.)

0: @[email protected]
0:yield
1: @[email protected]
1:yield
2: @[email protected]
2:yield
3: @[email protected]
3:yield
4: @[email protected]
4:yield
5: @[email protected]
5:yield
6: @[email protected]
6:yield
7: @[email protected]
7:yield
8: @[email protected]
8:yield
9: @[email protected]
9:yield
Ten: @[email protected]
10:yield
One: @[email protected]
11:yield
: @[email protected]
12:yield
: @[email protected]
13:yield
: @[email protected]
14:yield
: @[email protected]
15:yield
: @[email protected]
16:yield
: @[email protected]
17:yield
: @[email protected]
18:yield
: @[email protected]
19:yield
: @[email protected]
20:yield
£ @[email protected]
21:yield
: @[email protected]
22:yield
At: @[email protected]
23:yield
: @[email protected]
24:yield
: @[email protected]
25:yield
: @[email protected]
26:yield
: @[email protected]
27:yield
: @[email protected]
28:yield
£ º @[email protected]
29:yield
: @[email protected]
30:yield
£ º @[email protected]
31:yield
: @[email protected]
32:yield
: @[email protected]
33:yield
: @[email protected]
34:yield
: @[email protected]
35:yield
£ º @[email protected]
36:yield
Panax Notoginseng: @[email protected]
37:yield
: @[email protected]
38:yield
: @[email protected]
39:yield
Max: @[email protected]
40:yield
In: @[email protected]
41:yield
: @[email protected]
42:yield
: @[email protected]
43:yield
: @[email protected]
44:yield
: @[email protected]
45:yield
: @[email protected]
46:yield
: @[email protected]
47:yield
: @[email protected]
48:yield
: @[email protected]
49:yield
: @[email protected]
50:yield
Wuyi: @[email protected]
51:yield
: @[email protected]
52:yield
: @[email protected]
53:yield
Wu: @[email protected]
54:yield
: @[email protected]
55:yield
: @[email protected]
56:yield
£ º @[email protected]
57:yield
: @[email protected]
58:yield
: @[email protected]
59:yield
: @[email protected]
60:yield
: @[email protected]
61:yield
: @[email protected]
62:yield
: @[email protected]
63:yield
: @[email protected]
64:yield
: @[email protected]
65:yield
: @[email protected]
66:yield
: @[email protected]
67:yield
: @[email protected]
68:yield
: @[email protected]
69:yield
: @[email protected]
70:yield
: @[email protected]
71:yield
: @[email protected]
72:yield
: @[email protected]
73:yield
In: @[email protected]
74:yield
: @[email protected]
75:yield
: @[email protected]
76:yield
: @[email protected]
77:yield
: @[email protected]
78:yield
: @[email protected]
79:yield
: @[email protected]
80:yield

Thread, yield yields a CPU dispatch

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.