Can I use std::thread ?
Hi, I tried to make a std::thread in UE 4.11.2 and the editor immediately crashes. It compiles and the same source code works outside Unreal in a normal VS2015 C++ project.
So, I am doing something wrong or are std::thread not supported (yet)?
asked May 05 '16 at 05:34 PM in C++ Programming
If you can never use standard C++ library, UE4 has it's own API wrappers so use UE4 APIs as much as you can this allows UE4 and you game to compile on any platform that it support regardless of incompatibilities. So UE4 got his own threading system, VictorBurgos linked tutorial about it.
But regardless standard C++ should work either way (As well as 3rd party liberies, sometimes youy are forced to use std to communicate with them but you should alwasy convert them up to UE4 types when you start to mix them with engine), there probably some conflict with UE4 code that cause crash (note that UE4 is not aware of thread you making when you use std::thread), multithreading is very delicate matter, it other reason why you should avoid standard libraries,
,Actually I tried once. But finally I found it will cause a crash when using std::thread to make multi-thread program.
I'm not sure but I think UE4 using a thread pool instead of creating a new thread directly.Maybe people of Epic can tell me more about how the multi-thread system work in UE4
So I think you should not using std::thread :)
answered May 06 '16 at 06:49 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here