Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

multi threading using an iframe

I am trying to simulate multi threading using an iframe but I have come across a situation which I do not know if it actually utilizes the iframe process (thread) on its own.

For instance, If I call a method which lays inside an iframe, will it run using the thread created by the iframe or will it run using the main parent window thread?

If it is the latter, then is it possible to change the scope so that the iframe calls the method (so that the program uses a different thread from that of the parent window)

EDIT: Maybe I should have been more clear on this but I do not want to use WebWorkers simply because I do not have access to the DOM elements.

like image 719
fogy Avatar asked Aug 06 '11 13:08

fogy


People also ask

Can iFrames run on different threads?

To sum up the other answers: No, iFrames usually run in the same thread/process as the main page.

Is HTML multithreaded?

Multithreading is supported by all programming languages and platforms. But HTML never supported it. HTML programmers had to use setTimeout or setInterval to make the application behave like multithread application. But HTML5 provided built in API to support multithreading.

Can we make JavaScript multi threaded?

Thanks to recent advancements in the language--such as the Atomics and SharedArrayBuffers objects and Web Workers in the browser--JavaScript is now a multi-threaded language.

Is Web browser multi threaded?

“Today's browsers are inherently single-threaded,” explained Stephen Reeder, Commercial Director at Ekioh. “So if you're running on multi-core silicon, you're only using one of those cores.” “With multi-tabbed browsing, each tab has its own thread.


1 Answers

If you want to run some background tasks just use WebWorkers.

Generally you don't need to multi thread js code. You should use event loops instead.

like image 181
Raynos Avatar answered Oct 26 '22 16:10

Raynos