Dev from EU, currently working in frontend development, with knowledge of docker and kubernetes.
I love tinkering and staying up with the latest technology.
Parallel means there are multiple different things happening at the same time. You can listen to music and cook at the same time. You're doing these two things in parallel.
Asynchronous is used when you start some process, that you know will finish at some point, but you're not going to wait for it. Sending an email is asynchronous communication, because you send an email and you know that you'll get a reply some time in the future. Having a phone call is synchronous communication, since you have to wait for the other person to stop talking, so that you can talk and vice-versa.
You can combine the two. If you sent an email to several recipients, they can all be writing their replies at the same time (in parallel). But you'd still be waiting for their replies (while possibly doing other things).
An example asynchronous task is fetching some resource (some text lets say). You fire the request, then when it is finished some task happens (Promise/Callback).
An example for parallel task is processing something in the background, like calculating something that will that a long time).
constpossiblePrimes=[3,5,1233112,568543,6575323445];console.log(1);possiblePrimes.foreach((number)=>{// Creates a background task and starts it in 0 ms (meaning right now)setTimeout(()=>console.log(isPrime(number)),0);};console.log(2);
The above example would print 1 then 2 and them some sequence of true/false. Since the isPrime will be running in parallel the fastest result will be printed first (probably true for 3).
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Parallel means there are multiple different things happening at the same time. You can listen to music and cook at the same time. You're doing these two things in parallel.
Asynchronous is used when you start some process, that you know will finish at some point, but you're not going to wait for it. Sending an email is asynchronous communication, because you send an email and you know that you'll get a reply some time in the future. Having a phone call is synchronous communication, since you have to wait for the other person to stop talking, so that you can talk and vice-versa.
You can combine the two. If you sent an email to several recipients, they can all be writing their replies at the same time (in parallel). But you'd still be waiting for their replies (while possibly doing other things).
An example asynchronous task is fetching some resource (some text lets say). You fire the request, then when it is finished some task happens (Promise/Callback).
The above example would print
An example for parallel task is processing something in the background, like calculating something that will that a long time).
The above example would print
1
then2
and them some sequence oftrue
/false
. Since theisPrime
will be running in parallel the fastest result will be printed first (probablytrue
for3
).