关于python3中的多处理

时间:2018-04-15 14:58:53

标签: python multiprocessing

我使用多处理来设置2个过程 这是我的代码:

import multiprocessing 

def aaa():
    while True:
        print('aaa')

def bbb():
    while True:
        print('bbb')


if __name__=='__main__':
    p1=multiprocessing.Process(target=aaa())
    p2=multiprocessing.Process(target=bbb())
    p1.start
    p2.start
    p1.join
    p2.join

我希望它会打印出来:

  

' AAA'' BBB'' AAA'' BBB'' AAA'&# 39; BBB'' AAA'' BBB'' AAA'' BBB'' AAA&#39 ;,' BBB',

为什么只打印aaa,而不打bbb? 谢谢!

1 个答案:

答案 0 :(得分:0)

您正在调用Process,而不是将其传递给import multiprocessing def aaa(): while True: print('aaa') def bbb(): while True: print('bbb') if __name__=='__main__': p1=multiprocessing.Process(target=aaa) p2=multiprocessing.Process(target=bbb) p1.start() p2.start() p1.join() p2.join()

package com.example.unityplugin;

import android.bluetooth.BluetoothAdapter;

public class PluginClass {
public static String testMessage(){
    return "I AM WORKING";
}

public static String TurnOnBluetooth(){
    BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    if (bluetoothAdapter != null) {
        if (!bluetoothAdapter.isEnabled()) {
            bluetoothAdapter.enable();
            return "BLUETOOTH ON";
        } else {
            return "WAS ON";
        }
    }
    return "no bluetooth adapter";
}