I wanted to know if there is a way to use parallelism in javascript
.
For those who come from the world of java
or C
this is a well known and used term, the known threads
.
Parallelism = > is a program with the ability to divide tasks into small parts and run them in parallel.
I've been thinking of a process that is running in standy-by
as it can be done in lower level programming with while(1)
for example, waiting for the iteration of some external process, consuming some web-service
, while that this processing would not stop my application front-end
.
I do not know if with an image I can make it clearer ...
Forexamplethefollowingcode:
<imputid="a" type="text">
<script>
(function() {
x = a.value;
while (1) {
if (x === "string") {
alert("entrou");
}
}
)
function teste() {
alert("Sou uma função");
}
</script>
If it crashes it locks any browser, in fact it only hangs the page where it was executed because of while(1)
.... in my view, if it were possible to mount this in parallel processes, it would not crash.