I have been reading about the concept but still it doesn't make sense to me. I want to clarify my question by giving an example.
First of all, if we have task1 and task2 which have to run in sequence, they call it synchronous. Whereas, if task2 runs before task1 finishes, it is called asynchronous. I came across such descriptions everywhere.
Where I am confused is that, if the tasks does not in order(one starts after the other finishes) how come things end up like we ordered them when we code line by line?
Imagine I write a code where task2 needs the final result of task1. In old way we would do it as:
var x = task1();
var y = task2(x);
So now above task2 needs x as an argument. But x can only return when the task1 finishes. Isn't it? So how come above task2 can start before task1 finishes? How can this work asynchronous way to make sense? Can someone clarify even though my definitions might not be correct?