Synchronous vs Asynchronous


October 24, 2016 by Kenneth Fisher

You’ll hear these terms thrown around in programming all the time, but what do they mean and why do we care? Starting with simple definitions first:


  1. occurring at the same time; coinciding in time; contemporaneous; simultaneous.
  2. going on at the same rate and exactly together; recurring together.
  3. Physics, Electricity. having the same frequency and zero phase difference.
  4. Computers, Telecommunications. of, relating to, or operating using fixed-time intervals controlled by a clock (opposed to asynchronous ).
  5. Aerospace. geostationary.



  1. not occurring at the same time.
  2. (of a computer or other electrical machine) having each operation started only after the preceding operation is completed.
  3. Computers, Telecommunications. of or relating to operation without the use of fixed time intervals (opposed to synchronous ).


Honestly that’s less helpful than I expected. So I’m going to try my own definitions related specifically to running code along with an example of each.

Synchronous – Code that runs one one line at a time. Each line of code is completed before the next one starts. If an external call is made then it is completed before the next line of code runs.

Asynchronous – Code that is launched and runs separately from the initial code. If a SQL job is launched from inside a batch of code (using sp_start_job for example) then the job is running in parallel (at the same time as) to the remainder of the batch of code.

Ok, so why do we care?

Because sometimes we want to be able to start a piece of code without having to wait for it. Agent jobs and service broker are great ways to do this btw. For example inserting data into a table that needs to be processed but you don’t want to have to wait on the processing to commit the insert. On the other hand there are times when we want to start a job and wait for it to finish.

There are a lot of ways to handle this from both directions and it really depends on what you are doing. The important thing is to remember that the concept exists. That both options exist and know which you need.

4 thoughts on “Synchronous vs Asynchronous

  1. dallasbikr says:

    I was totally expecting an Availability Group article based on the title…but this may have actually given me a direction to handle some long running processes we have here…thanks!

  2. […] do this is to use code of some type. T-SQL isn’t going to work because we need these to run asynchronusly and not synchronously (all at the same time not one after the other) and T-SQL doesn’t have that option. You could […]

  3. […] JobStart had done was start LogShipping this wouldn’t be a big issue since SQL Agent Jobs are asynchronous and JobStart would already be done. However we have more code after the job started which, among […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 3,753 other subscribers

Follow me on Twitter

ToadWorld Pro of the Month November 2013
%d bloggers like this: