Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between asynchronous I/O and asynchronous function?

Node.js, is an asynchronous I/O. what does this actually mean?

Is there different between I create an async function by spawning another thread to do the process?

e.g.

void asyncfuntion(){
    Thread apple = new Thread(){
       public void run(){
           ...do stuff
       }
    }
    apple.start()
}

If there is difference, can I do a asynchronous I/O in javascript?

like image 206
TheOneTeam Avatar asked Sep 29 '11 04:09

TheOneTeam


People also ask

What is difference between synchronous and asynchronous function?

The differences between asynchronous and synchronous include: Async is multi-thread, which means operations or programs can run in parallel. Sync is single-thread, so only one operation or program will run at a time. Async is non-blocking, which means it will send multiple requests to a server.

What is asynchronous IO?

In computer science, asynchronous I/O (also non-sequential I/O) is a form of input/output processing that permits other processing to continue before the transmission has finished.

What is difference between sync and async function in Javascript?

Synchronous code runs in sequence. This means that each operation must wait for the previous one to complete before executing. Asynchronous code runs in parallel. This means that an operation can occur while another one is still being processed.

What is the function of asynchronous?

An asynchronous function is any function that delivers its result asynchronously – for example, a callback-based function or a Promise-based function. An async function is defined via special syntax, involving the keywords async and await . It is also called async/await due to these two keywords.


1 Answers

Asynchronous I/O

Asynchronous I/O (from Wikipedia)

Asynchronous I/O, or non-blocking I/O, is a form of input/output processing that permits other processing to continue before the transmission has finished.

What this means is, if a process wants to do a read() or write(), in a synchronous call, the process would have to wait until the hardware finishes the physical I/O so that it can be informed of the success/failure of the I/O operation.

On asynchronous mode, once the process issues a read/write I/O asynchronously, the system calls is returned immediately once the I/O has been passed down to the hardware or queued in the OS/VM. Thus the execution of the process isn't blocked (hence why it's called non-blocking I/O) since it doesn't need to wait for the result from the system call, it will receive the result later.

Asynchronous Function

Asynchronous functions is a function that returns the data back to the caller by a means of event handler (or callback functions). The callback function can be called at any time (depending on how long it takes the asynchronous function to complete). This is unlike the synchronous function, which will execute its instructions before returning a value.

...can I do a asynchronous I/O in java?

Yes, Java NIO provides non-blocking I/O support via Selector's. Also, Apache MINA, is a networking framework that also includes non-blocking I/O. A related SO question answers that question.

like image 107
Buhake Sindi Avatar answered Nov 12 '22 05:11

Buhake Sindi