Create 1000 threads in linux

Source: Internet
Author: User
Create 1000 threads in linux-general Linux technology-Linux programming and kernel information. For more information, see. To create 1000 threads, run ulimit-s 2048 first.

It is almost impossible to solve this problem using a program.

According to the posix thread of RedHat Linux 9.0, the parent process of each thread is the current console process, rather than the process that calls pthread_create. On the other hand, the number of threads that can be created in a process is mainly limited by the stack size: 2G/maximum stack size allowed, on the i386 platform, the maximum stack size of the console process is 8 MB by default, so the number of threads that can be created is 2G/8 M = 256. However, the 8 m limit can be modified by running the ulimit command to indirectly increase the number of threads that can be created.

In this way, your question evolves to "can you modify the maximum stack size parameter of the console process through a program ?". I personally think this is difficult to achieve through conventional methods.

Modify ulimit Parameters

[Root @ web230 ~] # Ulimit-n
1024

Take limit-n as an example.

Vi/root/. bash_profile

Add ulimit-HSn 10240 to save and exit

Source/root/. bash_profile

[Root @ web230 ~] # Ulimit-n
10240

Modified successfully.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.