程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python multi process problem

編輯:Python

The normal code should be the code of the main process and the sub process at the same time , But the results are printed out in order

The code is as follows :
from multiprocessing import Process

def ceshi():
for i in range(50):
print(i, " Son ")

if name == 'main':
a = Process(target=ceshi)
a.start()
for i in range(50):
print(i," Lord ")

Operation results and error reporting contents
0 Lord
1 Lord
2 Lord
3 Lord
4 Lord
5 Lord
6 Lord
7 Lord
8 Lord
9 Lord
10 Lord
11 Lord
12 Lord
13 Lord
14 Lord
15 Lord
16 Lord
17 Lord
18 Lord
19 Lord
20 Lord
21 Lord
22 Lord
23 Lord
24 Lord
25 Lord
26 Lord
27 Lord
28 Lord
29 Lord
30 Lord
31 Lord
32 Lord
33 Lord
34 Lord
35 Lord
36 Lord
37 Lord
38 Lord
39 Lord
40 Lord
41 Lord
42 Lord
43 Lord
44 Lord
45 Lord
46 Lord
47 Lord
48 Lord
49 Lord
0 Son
1 Son
2 Son
3 Son
4 Son
5 Son
6 Son
7 Son
8 Son
9 Son
10 Son
11 Son
12 Son
13 Son
14 Son
15 Son
16 Son
17 Son
18 Son
19 Son
20 Son
21 Son
22 Son
23 Son
24 Son
25 Son
26 Son
27 Son
28 Son
29 Son
30 Son
31 Son
32 Son
33 Son
34 Son
35 Son
36 Son
37 Son
38 Son
39 Son
40 Son
41 Son
42 Son
43 Son
44 Son
45 Son
46 Son
47 Son
48 Son
49 Son

My solution ideas and tried methods
I checked every code , All of them have been pounded exactly as on the computer , Not yet.

What I want to achieve
It should be staggered .


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved