Latest Questions tagged Multithreading

Browse all latest questions tagged Multithreading

60
Votes
Published 29 Oct, 2022
Java - Which data structure to use to store millions of objects in multithreading environment ( Scalability and performace )?

My requirement is like : I want to perform frequent operation on millions of objects in multi-threaded environment with concurrency and scalability keeping in mind, I need best data structure suitable...

81
Votes
Published 26 Oct, 2022
Java - How to find where a thread was originally started

Supposed I have an application that can spawn multiple threads if needed for doing tasks ... so nothing special. I use Eclipse to write and debug Java applications. A thread (lets call it "async task"...

16
Votes
Published 27 Aug, 2022
Python - Can I import modules from thread in Python?

It all began last night when I was making a script that required 8 or so packages including pygame.mixer which on my computer importing this takes a few seconds. This meant that before the script e...

76
Votes
Published 14 Sep, 2022
Java - Increment an int using threads

I have two threads and I want to increment an int variable while it is less than a certain value. My program does that but two different threads do not increment the value separately. If one and two a...

15
Votes
Published 29 Aug, 2022
Python - Executing tasks in parallel in python

I am using python 2.7, I have some code that looks like this: task1() task2() task3() dependent1() task4() task5() task6() dependent2() dependent3() The only dependencies here are as follows: dep...

81
Votes
Published 14 Sep, 2022
Java - Difference between java 8 streams and parallel streams

I wrote code using Java 8 streams and parallel streams for the same functionality with a custom collector to perform an aggregation function. When I see CPU usage using htop, it shows all CPU cores be...

184
Votes
Published 22 Aug, 2022
Python - multiprocessing.Pool: When to use apply, apply_async or map?

I have not seen clear examples with use-cases for Pool.apply, Pool.apply_async and Pool.map. I am mainly using Pool.map; what are the advantages of others?

33
Votes
Published 05 Oct, 2022
Java - how to use cassandra session for multiple threads?

I am using cassandra as backend in web application(in java), where for each user need to create unique session or use single one as in below url? I read session information in this link. https://docs...

99
Votes
Published 30 Jun, 2022
Python - How do I run background job in Flask without threading or task-queue

I am building REST API with Flask-restplus. One of my endpoints takes a file uploaded from client and run some analysis. The job uses up to 30 seconds. I don't want the job to block the main process....

118
Votes
Published 15 Sep, 2022
Java - Why is creating a Thread said to be expensive?

The Java tutorials say that creating a Thread is expensive. But why exactly is it expensive? What exactly is happening when a Java Thread is created that makes its creation expensive? I'm taking the s...

99
Votes
Published 07 Sep, 2022
Java - Reentrantlock - Why do we need to acquire a lock multiple times?

I have recently been learning multithreading concepts in java. I have a few doubts which didn't resolve by looking up the relevant threads on StackOverflow. I couldn't find satisfactory answers for my...

46
Votes
Published 21 Oct, 2022
Java - Make multiple API calls and return combined response in minimum time

I have 10 health check URLs which are simply get service I am hitting them in a loop like below for(int i=0;i<10;i++){ Response response = given().when().relaxedHttpsValidation().get(url[i]);...

83
Votes
Published 26 Jun, 2022
Python - Python 3: does Pool keep the original order of data passed to map?

I have written a little script to distribute workload between 4 threads and to test whether the results stay ordered (in respect to the order of the input): from multiprocessing import Pool import nu...

120
Votes
Published 06 Sep, 2022
Java - How can I monitor/log Tomcat's thread pool?

I have a Tomcat installation where I suspect the thread pool may be decreasing over time due to threads not being properly released. I get an error in catalina.out when maxthreads is reached, but I wo...

59
Votes
Published 23 Jun, 2022
Python - 'thread._local' object has no attribute

I was trying to change the logging format by adding a context filter. My Format is like this FORMAT = "%(asctime)s %(VAL)s %(message)s" This is the class I use to set the VAL in the format. class...