5
I was wondering if there’s a way to use parallelism in javascript
.
For those who come from the world of java
or of C
is a well-known and widely used term, known as threads
.
Parallelism => is a program with the ability to divide tasks into small parts and run them in parallel.
I kept thinking about a process that was running on standy-by
as well as can be done in the lowest level programming with while(1)
for example, that awaits the iteration of some external process, consuming some web-service
, as long as this processing did not stop my application front-end
.
I don’t know if with an image I can make it clearer...
For example the following code:
<imput id="a" type="text">
<script>
(function() {
x = a.value;
while (1) {
if (x === "string") {
alert("entrou");
}
}
)
function teste() {
alert("Sou uma função");
}
</script>
If running hangs any browser, it actually hangs only the page on which it was executed because of the while(1)
.... in my view, if it were possible to mount this in parallel processes, I would not.
@bfavaretto gave an answer on that subject here. It’s already a bit enlightening =]
– BrTkCa
So @Lucascosta, hit by bfavaretto’s answer, my question is more about whether there is a way to create threads of parallel processes :) it’s a little different the concept of asynchronous with thread
– MarceloBoni