简体   繁体   中英

It has any possible to create a thread to send request to server in background

I want to write a function that can send request to server continuously in background. But I don't know to use thread in React Native. Can you give me some and suggestions.and it is best don't use native codes.

Javascript is single-threaded, so you can't manage/create threads. You can read about the threading model here .

The interesting part for you is that network requests in javascript don't pause your thread. They always run in the background and will resume work on the JS thread once they are completed.

@RichardSleet you can do that with help of webworkers

A web worker is a JavaScript that runs in the background, independently of other scripts, without affecting the performance of the page so when you create new worker

each worker will have whole new CONTEXT

Example : You can run 10 for loops parallely with webworkers

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM