joltup / react-native-threads

Create new JS processes for CPU intensive work
MIT License
756 stars 142 forks source link

terminate not working for a process running infinite loop #72

Closed DillionApple closed 5 years ago

DillionApple commented 5 years ago

When I start a process using react-native-threads which runs a infinite loop, calling the terminate() on the thread does not seem to work.

DillionApple commented 5 years ago

Solved. The process react-native-threads created is a JS thread, and use an event loop to to execute tasks. Since the infinite loop does not release the execution right, the "terminate" event will never be picked up. We replace the infinite loop to an JS "setInterval" block to solve this problem.