4,734 questions
0
votes
1
answer
83
views
What’s the difference between concurrency and parallelism on a single CPU core with 2 hardware threads?
Let's say I have a CPU with 1 core and 2 hardware threads (for example, with Intel Hyper-Threading or AMD SMT).
From what I understand, that means the core can run two software threads "at once&...
2
votes
1
answer
71
views
Cannot start a ThreadPoolExecutor inside a threading.Thread function
In this example, Tkinter GUI starts ThreadPoolExecutor. But ThreadPoolExecutor is inside a threading.Thread function. The thread function says it's finished
before ThreadPoolExecutor has started ... ...
0
votes
1
answer
68
views
subprocess.run() eventually reaches python's global thread limit
I have a python script that pings another device every so often.
PING_SIZE = "1"
PING_RETRYS = "1"
while True:
try:
result = subprocess.run(
["ping&...
-1
votes
1
answer
126
views
Get the list of cancelled tasks which were in progress when the executor was shut down
LISTING 7.21 ExecutorService that keeps track of cancelled tasks after shutdown.
public class TrackingExecutor extends AbstractExecutorService {
private final ExecutorService exec;
private ...
1
vote
1
answer
77
views
Thread pool implementation do not end properly when joined
I am working on a Rust project (as a side-training project) to implement a HEIC (Apple iPhone picture format) to JPEG converter. Full code is already available here. Within this project I am trying to ...
0
votes
0
answers
100
views
Multithreading issue with GIL for CPU-bound task in Python
I'm learning about multithreading in Python, and am experimenting to see how GIL(Global Interpretor Lock) works.
Given the following python code:
def cpu_bound():
i = 0
for _ in range(10000000):
...
0
votes
1
answer
85
views
How best to handle an exception in a third party method called by ThreadPool.QueueUserWorkItem?
I am working with a third party library that calls a method using ThreadPool.QueueUserWorkItem(). However, an exception is occurring within that method and I'd like to know how to best handle it in my ...
3
votes
0
answers
138
views
Why are thread pools so significantly slower than parallelStream for this scenario?
This is for Java 23, but I've replicated this on Java 21 and 17 as well.
I recently ran a benchmark to compare performance differences between threadpools and parallelstreams for some simple ...
0
votes
1
answer
117
views
Actual practical advantage of SQLAlchemy scoped_session vs classic session in worker
What is the actual practical advantage of using a scoped_session vs a normal session when using a contextmanager to handle opening and closing of the session at the appropriate times?
In the following ...
3
votes
2
answers
143
views
Run background process in high priority TaskScheduler
I have legacy codebase that is starving ThreadPool because of many sync calls (instead of using async/await). I am trying to create background process that will prolong kubernetes lease due to ...
0
votes
0
answers
83
views
How to Efficiently Process a Concurrent Queue Using a Thread Pool in Java?
I'm working on a Java application where I need to periodically check a MongoDB collection (CacheBilgi) and enqueue new data into a concurrent queue (cacheInfoQueue). Then, I need to process this queue ...
1
vote
0
answers
109
views
Managing ThreadPool and Connection Pool sizes with CompletableFuture for concurrent third-party API calls
I'm working on implementing concurrent third-party API calls for items in a list using CompletableFuture in Java. Instead of processing these requests sequentially, I want them to be executed ...
1
vote
1
answer
346
views
How to implement thread pool without ExecutorService
I am trying to work on some understanding on thread pools and am trying to implement one by myself without using the ExecutorService. But getting into waiting state for some reason and I am not sure ...
3
votes
1
answer
189
views
Delphi TThreadPool destructor causes a deadlock from DLL built with the runtime packages
The basic problem lies in the implementation of the RTL library as soon as the ThreadPool destructor collides with the FreeLibrary limitations. TThreadPool.Destroy has a fix to address this issue, ...
1
vote
1
answer
274
views
Virtual Thead Names on Intellij Debugger
Issue with Virtual Threads in IntelliJ Debugger
When using virtual threads in IntelliJ, the thread name is not displayed correctly in the debugger, even when explicitly set. Instead, it shows a ...
1
vote
1
answer
89
views
Handling return values in a thread pool (C)
I am a novice in C programming, a topic I am currently learning about is threading and multiprocessing. Using the api provided via pthread.h, I am implementing a priority thread-pool. It uses a heap ...
0
votes
2
answers
200
views
Are there limits on the values we can set for ThreadPool.SetMinThreads and ThreadPool.SetMaxThreads?
I'm working on ASP .NET Core project, where I have classes managing a pool of worker threads for task execution, and I'm using the .NET thread pool to handle and execute tasks for processing incoming ...
0
votes
1
answer
47
views
MapReduce - round-robin scheduling of mappers?
I was going through OSTEP's concurrency-mapreduce project which essentially involves building a toy MapReduce program which runs on a single machine using multiple threads. Towards the end, of the ...
1
vote
1
answer
185
views
How can I use TTask and TThreadPool in Delphi to run multiple tasks and ensure that its start and completion are reported accurately?
I am trying to implement multithreading in Delphi 10.4 (Sydney). I am using TTask to run tasks concurrently and TThreadPool to limit the simultaneously running threads.
Here's my code:
var
...
1
vote
2
answers
274
views
Implement multithreading with a queue in Delphi to limit to n threads running simultaneously?
I have been working with Delphi for some time, and am now trying to implement multi-threading in my code with the following requirements:
Only 2 threads should run at a time.
Other tasks should wait ...
0
votes
0
answers
152
views
SpdLog, RuntimeError: async log: thread pool doesn't exist anymore
Here is my code, if I enabled async_mode=True, I will get
Traceback (most recent call last):
File "/root/tradebot-pro/example/test_log.py", line 28, in <module>
logger1.info(&...
0
votes
0
answers
70
views
Is there way to configure LDAPConnectionPool to kill idle connections after exceeding some "keepAliveTime"
I create an LDAPConnectionPool the following way:
LDAPConnectionPool(
connection,
1,
20,
StartTLSPostConnectProcessor(getSslContext()),
).let {...
2
votes
1
answer
176
views
How to run the same QRunnable in a QThreadPool multiple times?
I'm reading the french book "Maîtrisez Qt 5: guide de développement d'applications professionnelles" to learn Qt.
There is a small code in it to explain QThreadPool :
#include "MaTache....
4
votes
1
answer
242
views
SetThreadpoolTimerEx occasionally does not invoke callback
I am experiencing a rare issue where SetThreadpoolTimerEx does not invoke the callback function as expected.
Environment:
Operating System: Windows 10 22H2 (Build 19045.5131)
Visual Studio: 2022 (...
0
votes
2
answers
520
views
How to clean up thread-local data after using ThreadPoolExecutor?
I want to use ThreadPoolExecutor to parallelize some (legacy) code with database access. I would like to avoid creating a new database connection for each thread, so I use threading.local() to keep a ...
0
votes
0
answers
50
views
Why Threadpool queue the task instead of reusing the idle threads
Creation of ThreadPool
@PostConstruct
public void postConstruct() {
threadPool = new ThreadPoolExecutor(corePoolSize != 0 ? corePoolSize : defaultPoolSize, maxPoolSize != 0 ? maxPoolSize : ...
0
votes
1
answer
95
views
KeyboardInterrupt doesn't work as expected
Ask please why press Ctrl + C ( KeyboardInterrupt) does not work as expected. (the process is not interrupted, continues to work)
from concurrent.futures import ThreadPoolExecutor
def sleeper(n):
...
0
votes
1
answer
84
views
Logging from winapi callbacks
I am developing a C application in Visual Studio 2022, using winapi. I have some issues regarding logging (for debug purposes) from callbacks when using winapi thread pools. Below is a minimal example ...
3
votes
1
answer
199
views
What is the difference between "JVM thread_state" and "java.lang.Thread.State" in a thread dump?
In below thread dump, there seems to be two different thread states: JVM thread_state and java.lang.Thread.State. Which one is the actual state of the thread?
JVM thread_state is "_thread_blocked&...
4
votes
2
answers
160
views
Is my code causing deadlock ? I'm not sure. Could someone confirm or disconfirm?
For a new project at my new job, the tech lead and architect asked me to learn and use boost::asio. Specifically the class thread_pool of the library.
Let me put things in context.
We are building an ...
0
votes
0
answers
30
views
Unable to save values in sequence during parallel processing in Python
I have below code:
from datetime import datetime, timezone, timedelta
from time import sleep
from services.ldap import LDAP
import aiohttp
import os
from conf.settings import Settings as settings
...
4
votes
1
answer
531
views
How can I avoid thread pool exhaustion and deadlocks in this .NET Core Web API using async/await?
I’m working on a .NET Core Web API, and I’ve encountered performance issues and potential deadlocks when calling asynchronous methods. I suspect that I'm using async and await incorrectly. Below is ...
0
votes
1
answer
91
views
Python Thread pool hanging the application
i am currently running the below python script:
# Function to process MMR search
def process_mmr_search(row, itemdesc):
try:
formatted_itemdesc = str(row[itemdesc])
print('...
0
votes
1
answer
55
views
Efficient way to check if we should exit a working thread
It's like a thread-pool context. I have a global atomic variable which indicates if working threads should exit:
atomic<bool> exit;
Such working threads are executed in a loop this way:
while (...
0
votes
2
answers
131
views
Utilize multiprocessing in Python with functions that do not return any value
Consider the following codes in Python:
from multiprocessing import Pool
data = [4] * 10
def update(j):
data[j] += j ** 2
def solver():
with Pool(8) as po:
po.map(update, range(10))
...
1
vote
3
answers
3k
views
Python ThreadPoolExecutor: how to submit inside a function submitted
I am using Python's concurrent.futures library with ThreadPoolExecutor and I want to submit inside a function submitted. The following code is a minimal example trying to submit f2 inside submitted ...
1
vote
0
answers
63
views
What's the difference between all of the ways to supply an Executor to a CompletableFuture (and composed methods)?
I'm using Java's CompletableFutures for a project, and I got a bit confused on how there are multiple ways to pass an Executor to a CompletableFuture to pass control off to a different thread. ...
1
vote
2
answers
87
views
Taskpool not working while calling task with Arguments
I am creating a threadpool by using "https://github.com/alugowski/task-thread-pool/" and calling task using submit function but getting error
int Model::sum(int a, int b)
{
...
-2
votes
1
answer
97
views
How to Properly Handle InterruptedException When Task Needs to Continue?
In my current Java code, I have the following structure:
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
// return;
}
method1();
method2();
...
0
votes
1
answer
326
views
How to dynamically add a thread or pick a thread from the pool of thread in python
I'm looking to schedule tasks to be executed by threads, with the ability to dynamically add or remove tasks from the process. My goal is to pre-create a pool of threads, for example, [th1, th2, th3], ...
0
votes
1
answer
44
views
Unable to get Spring `@Async` to run on dedicated threadpool
I was expecting the below code to spend 1 second in the below test, but it takes 5 seconds. I ran it by ChatGPT and it found no issues either. What could be the issue preventing Spring from running ...
2
votes
1
answer
81
views
Can a task executed by C++ std::async(std::launch::async...) be switched/stolen between threads?
In C++ on Windows, given a task started by std::async(std::launch::async, ...), can it be executed first by one thread, and after a possible context switch, stolen and executed by another thread?
For ...
0
votes
1
answer
596
views
How to pass MDC data from main thread to webserver http threads
I'm using Spring Boot and MDC to log additional context with each log entry in my REST API application. I use MDC in the main thread, but the data is not passed to the http threads that are created ...
0
votes
1
answer
89
views
OpenCV displays black windows for multiple USB camera streams using multithreading
I'm working on a project that involves streaming from a few USB cameras simultaneously using Python and OpenCV. I've been experimenting with multithreading to handle both camera streams concurrently, ...
0
votes
1
answer
97
views
Cannot read the object while using thread pools to process
I have to design a server with 3 main thread pools in order to read the data, process them and output the results to the client. I code like this but it always notice this kind of bug:
java.io....
0
votes
2
answers
148
views
how to implement thread-pool continuation?
I have a rather simple threadpool implementation for which I need to write a continuation. When a task is enqueued in threadpool it returns an std::future. A caller can then want to enqueue tasks that ...
1
vote
1
answer
79
views
Python multiprocessing.pool apply_async callback function fails to re-order output data
I am using the multiprocessing.pool apply_async function to process some video data via a computer vision algorithm, and the current strategy to speed up the process, since the algorithm has no memory,...
0
votes
0
answers
93
views
ExecutorService awaitTermination does not wait for threads to complete and terminates main thread immediately
I have created a ExecutorService having 3 threads using which I'm trying to process a list each having 2MM objects. I'm calling below 2 methods after submitting the 3 tasks.
executorService.shutdown();...
-2
votes
1
answer
96
views
Timers, Tasks and Threads?
I have an application that consumes four inputs (web cam). For each of these inputs I'm trying to call an API every 200ms. The API doesn't return within 200ms - and in reality, I only need to ensure ...
0
votes
1
answer
67
views
C++ Threadpool: Why doesn't it scale perfectly on Android & Arm Tablet
I am trying to write a threadpool that divides linearly separable functions (loops) among threads. On my X86 laptop the threadpool scales linearly to the microsecond. On an Arm Tablet (Big Little ...