How to pass parameters to a Thread object?
问题 I'm working with a C++ class-library that provides a Thread base-class where the user has to implement a run() method. Is there a recommended way on how to pass parameters to that run() method? Right now I prefer to pass them via the constructor (as pointers). 回答1: I'm not sure about C++, but that's how you would do it in Java. You'd have a class that extends Thread (or implements Runnable) and a constructor with the parameters you'd like to pass. Then, when you create the new thread, you