Source_UDPServer *w = new Source_UDPServer(&tNod);
我让它像这样工作。谢谢大家
答案 0 :(得分:1)
线程运行的函数的参数可以作为线程对象构造函数的附加参数提供。请尝试以下方法:
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Set the view controller toolbar items
let items = [UIBarButtonItem(title: "Button Text", style: .plain, target: nil, action: nil)]
setToolbarItems(items, animated: false)
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// Show navigation controller’s built-in toolbar
navigationController?.setToolbarHidden(false, animated: false)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
// Hide navigation controller’s built-in toolbar
navigationController?.setToolbarHidden(true, animated: false)
}
}
请参阅std::thread::thread
重载#3。请注意,所有参数都通过move或value传递。如果您需要通过引用传递,请参阅std::ref
。