help icon indicating copy to clipboard operation
help copied to clipboard

Will it be possible to implement the function of 'start', 'pause', 'resume', 'stop', just same as what multi-threads of JAVA do?

Open jasonsun001 opened this issue 3 years ago • 2 comments

What is the problem this feature will solve?

To control the process of tasks which cost long time, for example, uploading and downloading files, data collecting, etc.

What is the feature you are proposing to solve the problem?

To control the process of tasks which cost long time, for example, uploading and downloading files, data collecting, etc.

What alternatives have you considered?

Promise

jasonsun001 avatar Feb 05 '22 05:02 jasonsun001

Moving to help repo so someone posts links to that article about how to break up long running work with setImmediate

benjamingr avatar Feb 05 '22 08:02 benjamingr

pause , resume and stop methods are inherently buggy and can potentially cause inconsistencies to the entire app. For that matter, Java have either deprecated or removed those APIs.

You can use custom events to control the thread's life cycle. For example:

worker.on('message', (message) =>
      // do what you need to do with the message
})

in the absence of this message and any other activities, the thread is waiting, and is practically free (in the underlying system), so will effectively give you the same result as pause and resume

Hope this helps!

gireeshpunathil avatar Jun 21 '22 03:06 gireeshpunathil

It seems there has been no activity on this issue for a while, and it is being closed in 30 days. If you believe this issue should remain open, please leave a comment. If you need further assistance or have questions, you can also search for similar issues on Stack Overflow. Make sure to look at the README file for the most updated links.

github-actions[bot] avatar May 08 '24 01:05 github-actions[bot]

It seems there has been no activity on this issue for a while, and it is being closed. If you believe this issue should remain open, please leave a comment. If you need further assistance or have questions, you can also search for similar issues on Stack Overflow. Make sure to look at the README file for the most updated links.

github-actions[bot] avatar Jun 08 '24 01:06 github-actions[bot]