Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9233599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:35:33+00:00 2026-06-18T06:35:33+00:00

# data is a list Threading_list=[] class myfunction(threading.Thread): def __init__(self,val): ……. ……. def run(self):

  • 0
# data is a list  

Threading_list=[]

class myfunction(threading.Thread):

    def __init__(self,val):
        .......
    .......

     def run(self):
        .......
        ....... 

for i in range(100000):

    t=myfunction(data[i]) # need to execute this function on every datapoint 
    t.start()
    Threading_list.append(t)

for t in Threading_list:
    t.join()

This will create around 100000 threads, but i am allowed to create a maximum of 32 threads ?
What modifications can be done in this code ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T06:35:34+00:00Added an answer on June 18, 2026 at 6:35 am

    So many Python threads rarely need to be created. Even more, I hardly can imagine a reason for that. There are suitable architectirual patterns to solve the tasks of creating code executing in parallel that limit the number of threads. One of them is reactor.

    What are you trying to do?

    And remeber that, due to GIL, Python threads do not give any performance boost for computational tasks, even on multiprocessor and multiple kernel systems (BTW, can there be a 100000-kernel system? I doubt. :)). The only chance for boost is if the computational part is performed inside modules written in C/C++ that do their work without acquiring GIL. Usually Python threads are used to parallel the execution of code that contains blocking I/O operations.

    UPD: Noticed the stackless-python tag. AFAIK, it supports microthreads. However, it’s still unclear what are you trying to do.

    And if you are trying just to process 100000 values (apply a formula to each of them?), it’s better to write something like:

    def myfunction(val):
        ....
        return something_calculated_from_val
    
    results = [myfunction(d) for d in data] # you may use "map(myfunction, data)" instead
    

    It should be much better, unless myfunction() performs some blocking I/O. If it does, ThreadPoolExecutor may really help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following data structure: List<Person> People; class Person { List<Car> Cars; List<Hobby> Hobbies;
A friend sent me his threading class. Now I just want to run a
I have a thread which produces some data (a python list) and which shall
Basically I've got a little threading class used by ExecutorService and a fixed thread
//initialize the people data list - (void)initializePeopleListFromJson:(CLLocationCoordinate2D)coordinate auraId:(NSString *)auraId { //initialize the NSMutableArray list
In below data list represents set of question's and answer, How to check whether
When I tried To Find Control n data List As I Mentioned Below Error(Object
I want to disable the button that is contained in a data list row.
In my ASP.NET Web-form Project I have an Event which Export Data ( List<Profit>
This is my code for counting lines and words: import System.IO import Data.List main

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.