delay function

Use with header files in VC
  #include <windows.h>
  Notice:
  The first English character in Sleep in VC is an uppercase "S"
  In standard C, it is sleep, do not capitalize. The following uses uppercase to explain, what to use depends on what compiler you use. Simply put, VC uses Sleep, and everything else uses sleep.
  The general form of the Sleep function:
  Sleep(unisgned long);
  Among them, the unit in Sleep() is in milliseconds, so if you want the function to stay for 1 second, it should be Sleep(1000);
  example:
  #include <windows.h>
  intmain()
  {
  int a;
  a=1000;
  Sleep(a); /* VC uses Sleep*/
  return 0;
  }

usleep function:
Pause execution. Syntax: void usleep(int micro_seconds); Return Value: None Function Type: PHP System Function Description: This function can temporarily stop the execution of the program. The parameter micro_seconds is the number of milliseconds to pause (microseconds or milliseconds?). Note: This function does not work on Windows operating systems. See also: usleep() Similar to sleep(), it is used to delay suspended processes. The process is suspended and placed on the rede queue.
  Just in general, when the delay time is on the order of seconds, use the sleep() function as much as possible.
  Also, this function has been deprecated and nanosleep can be used.
  If the delay time is tens of milliseconds, or less, use the usleep() function as much as possible. This allows the best use of CPU time

delay:
function name: delay
  Function: Pause the execution of the program for a period of time (milliseconds)
  用 法: void delay(unsigned milliseconds);
  Program example:
  /* Emits a 440-Hz tone for 500 milliseconds */
  #include<dos.h>
  int main(void)
  {
  sound(440);
  delay(500);
  nosound ();
  return 0;
  }
  (Because the delay is pronounced like a mine, it is commonly used in major OI irrigation areas...)


delay() is a circular wait, the process is still running, occupying the processor.   
Unlike sleep(), it will be suspended, yielding the processor to other processes.

The sleep() parameter specifies the pause time, in s   
The delay() parameter specifies the pause time in ms

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325864009&siteId=291194637