Questions tagged [synchronous]

Synchronous means that the caller of a function waits for the response or completion of the function before returning control to the main program

Synchronized means "connected", or "dependent" in some way. In other words two synchronous tasks must be aware of one another, and one must execute in some way that is dependent on the other. In most cases that means that one cannot start until the other has completed.

Synchronous (one thread):

1 thread ->   |----A-----||-----B-----------||-------C------|

Synchronous (multi-threaded):

thread A -> |----A-----|   
                        \  
thread B ------------>   ->|-----B-----------|   
                                              \   
thread C ---------------------------------->   ->|-------C------| 
1628 questions
1361
votes
22 answers

Asynchronous vs synchronous execution. What is the difference?

What is the difference between asynchronous and synchronous execution?
tush1r
  • 19,443
  • 14
  • 36
  • 35
483
votes
16 answers

asynchronous and non-blocking calls? also between blocking and synchronous

What is the difference between asynchronous and non-blocking calls? Also between blocking and synchronous calls (with examples please)?
user331561
  • 4,921
  • 3
  • 16
  • 5
208
votes
10 answers

What is the difference between synchronous and asynchronous programming (in node.js)

I've been reading nodebeginner And I came across the following two pieces of code. The first one: var result = database.query("SELECT * FROM hugetable"); console.log("Hello World"); The second one: database.query("SELECT * FROM…
Azeirah
  • 6,176
  • 6
  • 25
  • 44
206
votes
4 answers

jQuery: Performing synchronous AJAX requests

I've done some jQuery in the past, but I am completely stuck on this. I know about the pros and cons of using synchronous ajax calls, but here it will be required. The remote page is loaded (controlled with firebug), but no return is shown. What…
Industrial
  • 41,400
  • 69
  • 194
  • 289
141
votes
9 answers

How to wrap async function calls into a sync function in Node.js or Javascript?

Suppose you maintain a library that exposes a function getData. Your users call it to get actual data: var output = getData(); Under the hood data is saved in a file so you implemented getData using Node.js built-in fs.readFileSync. It's obvious…
abbr
  • 5,361
  • 6
  • 30
  • 44
112
votes
8 answers

Simplest way to wait some asynchronous tasks complete, in Javascript?

I want to drop some mongodb collections, but that's an asynchronous task. The code will be: var mongoose = require('mongoose'); mongoose.connect('mongo://localhost/xxx'); var conn =…
Freewind
  • 193,756
  • 157
  • 432
  • 708
98
votes
12 answers

document.createElement("script") synchronously

Is it possible to call in a .js file synchronously and then use it immediately afterward?