Public Class Methods in Threads | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Public Class Methods in Threads

How can you create a thread of a Class method?Creating a thread is like this "thread thr(func);" You just pass in a function pointer. But doing this with a method doesn't work "thread thr(obj.method);" What should I do?

22nd Apr 2018, 8:40 AM
xaralampis_
xaralampis_ - avatar
3 Answers
+ 1
depends on language.... At example in java you can pass to Thread ctor an Runnable implementer child where work of thread is defined in run() method
24th Apr 2018, 11:53 AM
KrOW
KrOW - avatar
+ 1
I dont know much new C++ standard but seem that using std:thread you have to use function only for multithreading... Anyway you can start thread directly inside the method
24th Apr 2018, 12:10 PM
KrOW
KrOW - avatar
0
Cpp?
24th Apr 2018, 12:01 PM
xaralampis_
xaralampis_ - avatar