When developing NSE scripts that perform operations in parallel, you don't need to worry about protecting memory resources because Nmap is single-threaded. However, network resources such as sockets or network bandwidth do need to be considered if we are working with a large number of script instances.
stdnse NSE library supports the creation of NSE threads that can run inside your script's Lua thread, and performs network operations in parallel.
stdnse.new_thread() function creates a new NSE thread. This function takes as the first parameter the function to execute in the new thread and, optionally, the arguments needed for the worker thread's main function. To create an NSE worker, you must load ...