Firstly, this is the first time I use multithreading, so, forgive me.
I found a subject talking about threads in wxWidgets, and I have created an example to use threads, but I don't know if that code works correctly, because it doesn't take any time to be executed.
#include <wx/thread.h>
// The declaration
class CThread : public wxThread {
public:
CThread() = default;
~CThread() = default;
void *Entry();
};
// The definition
void* CThread::Entry() {
const int maximum = 1000000;
for (unsigned int i = 0; i <= maximum; i++) {
if (i == maximum) {
wxLogMessage("The counter is finished.");
}
}
return 0;
}
// Main function
wxThread *thread = new CThread();
thread->Create();
thread->Run();
The previous example is a very simple example to use threads and that's what I want.
The ambiguous thing in that example doesn't take any time to be executed, and I don't know if that example is correct or not.
Is that code correct or there's something I missed?