In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article shows you how to use the multi-threaded PowerShell module MultiThreadTaskRunner, which is concise and easy to understand. It will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
Application scenario
Multithreading is quite useful when you need to batch process some tasks, and it is also more helpful to make full use of the capabilities of existing computers. All major development languages support multithreading.
By default, PowerShell, as a scripting language, does not support multithreaded operations. Although there are so-called background tasks, it is actually quite troublesome to control.
Solution
I like PowerShell very much, so I wrote a custom module to implement multithreading. The module is written in C # and the source code can be accessed at the following address
Https://github.com/chenxizhang/MultiThreadTaskRunner
At the same time, this module has been packaged and released to Microsoft's official PowerShell Gallery
Https://www.powershellgallery.com/packages/MultiThreadTaskRunner/1.0
How to use
To use this module, you first need to install it (please open PowerSehll as an administrator)
Install-Module-Name MultiThreadTaskRunner
Next, prepare a script block for testing
$script = {
Param ($obj)
Write-Host $obj
}
Please note that this is only implemented in the simplest code, outputting data based on a parameter passed in
The third step, you can use it quickly.
New-MultiTaskJob-Source 1.. 100-Block $script-ThreadCount 10
What this command means is to use 10 parallel threads to process the 100 numbers passed in, and actually assign 10 numbers to each thread, and then execute it using the previously defined script block.
Please note that you can see that the output is not in the order of 1 to 100, which proves that these numbers are actually processed by different threads.
The above content is how to use the multi-threaded PowerShell module MultiThreadTaskRunner. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.