Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

What is the difference between synchronous and asynchronous functions?

0
Posted

What is the difference between synchronous and asynchronous functions?

0

This probably depends on “who you ask”. Generally, something is Asynchronous when it happens without influence of something else. In the case of functions, they are almost always Synchronous in the sense that a function is called by some part of your code, and you get back to the calling function when the callee finishes. You can use asynchronous calls in some OS’s to read or write data to/from files – This is called “Asynchronous IO”. This works along the principles of: 1. You send a packet off to the filesystem to be written. 2. The write function returns almost immediately. 3. (Optionally) Some other code runs in the application. 4. Application waits on some synchronization object (e.g. a semaphore) for the write to complete. There are plenty of other cases of asynchronous behaviour in computer systems – I’d need more specifics on what you are referring to, if you want more details. To make an asynchronous function synchronous, you’d have to implement the “wait” inside the function,

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123