player_thread.start() print("player_thread created") machine_thread.start() print("player_thread created") player_thread.join() print("player_thread created") machine_thread.join() print("player_thread created") 什么调试语句都失败了
时间: 2023-08-16 08:08:12 浏览: 95
你可以尝试在创建进程时将 target 参数指定为函数对象,而不是函数的调用结果。修改后的代码如下:
```python
if __name__ == '__main__':
wg = WordGuessing()
player_thread = Process(target=wg.run_player_game)
machine_thread = Process(target=wg.run_machine_game)
player_thread.start()
machine_thread.start()
player_thread.join()
machine_thread.join()
```
这样应该就可以正常运行了。请注意,函数对象不要加括号,即不要写成 `wg.run_player_game()`,而应该写成 `wg.run_player_game`。
阅读全文