Newest 'multithreading' Questions - Stack Overflow

Questions tagged [multithreading]

Multi-threading is the ability of a computer or a program to perform work concurrently or asynchronously by utilizing multiple concurrent streams of execution (generally referred to as threads).

0
votes
0answers
4 views

What happens when os.system() is executed in python thread?

I am new to python threading. I am trying to understand what happens when os.system() is called from a python thread. I understand that threads do share file descriptors, heap, code and global ...
0
votes
0answers
11 views

Calling Semaphore bounded thread from function results in `NameError: name 'sema' is not defined`

If I want to limit the number of threads to create, I use a Semaphore like in the example below def TestFunction( m, n ): sema.acquire() print(m+n) sema.release() maxthreads = 2 sema = ...
0
votes
1answer
47 views

What is the equivalent of C++'s Futures in Java

I was looking for an asynchronous way of setting a variable and notify the possible listeners that the variable is now available. C++ has a great API for this use case called std::future (wait and ...
0
votes
0answers
26 views

C# Winforms - Update form label from another class inside a loop without block UI [duplicate]

I have a super basic winforms app, it has a button and a label on it, all of my 'Business Logic' is contained within completely separate classes. what i want to achieve is from my class i have a for ...
0
votes
0answers
22 views

Process doesn't finish after closing a window

I'm building a chat app on python using sockets and tkinter. Everything works correctly on Windows, but when i try to run it on Ubuntu some problems occurred. If i try to close an application window, ...
0
votes
0answers
20 views

Need clarification about executing C program through python threads

I am new to threading in python. I wrote the following python code and now trying to understand what happens when I execute it. You can see that the python code creates three threads and all of them ...
1
vote
0answers
40 views

Troubleshooting irregular OutOfMemoryError: unable to create new native thread

I have a Ubuntu 16.04.5 server which runs multiple Java applications as root. The applications regularly (about every 30min to 1h) crash from a OutOfMemoryError: unable to create new native thread. ...
0
votes
1answer
18 views

Elasticsearch optimistic locking

I have an application that receives events on different threads, each event is processed, formatted into different attributes, and saved into ElasticSearch. I would like to add a new entry in my DB ...
1
vote
1answer
26 views

Implementing a mutex with test-and-set atomic operation: will it work for more than 2 threads?

I'm reading the Wikipedia article on the test-and-set atomic operation. It says that one way to implement mutual exclusion is by using a test-and-set based lock. However, according to the same ...
1
vote
2answers
37 views

Calling a method only once with multiple threads

I have a web application which serves a lot of requests at the same time. In one of the app's API methods, I have a method - methodA(). In this method, I have a call to another method - doSomething()....
-1
votes
0answers
15 views

Multithreaded single process perfoms worse than multiple processes

I'm writing a .net application which iterates over several folders and perfoms multiple tasks on each. I've tried utilizing multithreading to speed up this process using Parallel.Foreach to iterate ...
-1
votes
1answer
39 views

Running a piece of code by creating a single thread speeds-up execution

I am trying some benchmarks using Intel AVX2 and Posix threads. Let's suppose that I am trying to find the minimum value in a sample. When I create a simple program I run the avx_min function. When I ...
0
votes
7answers
73 views

When does 'await' immediately leave a method and when does it not?

In programs utilizing async-await, my understanding is like this: an async method that IS NOT awaited will run in the background (?) and rest of the code will continue to execute before this non-...
0
votes
1answer
28 views

Inline Thread objects runs much faster than class that inherits from Thread

Here is a main that runs a simple counting loop three ways: Single-threaded 2 threads using inline code that creates two distinct Thread objects 2 threads using instances of the CountingThread class ...
0
votes
1answer
15 views

knex use count() result as a value for inserting a new row

I'm trying to use count() result as a value for inserting a new row. The issue is that in case of multithreading I'm getting a wrong value for count(), as the current code doesn't work properly with a ...
1
vote
1answer
36 views

How do you set the proper number of threads when executing concurrency task on iOS device?

I developed a cross-platform c++ library which spawn threads at runtime. I used a concurrency queue to dispatch computing tasks, thus every thread will be busy at most of the time. Now the question ...
0
votes
2answers
73 views

Why does my code run on multiple threads?

Since a pretty long time I'm trying to understand async-await stuff in .NET, but I struggle to succeed, there's always something totally unexpected happening when I use async. Here's my application: ...
-1
votes
1answer
22 views

Explanation on Main thread Execution with await keyword

I have read a dozen articles about async/await and they all have been a great read. But in all those articles some confusions/questions weren't addressed. I have seen on this forum too (this awesome ...
0
votes
0answers
15 views

How to explain thread synchronization mechanism at OS level conceptually?

There is lot of discussion on thread synchronization on SO as well as on many forums all-over the Internet. However, I could not find precise information as to how exactly it happens at OS level ...
-2
votes
0answers
34 views

Down program when use executor [on hold]

We have stream that countine anytime, (note: we have one thread) for processing stream so fast, we makecollection (BlockingQueue) and fill that with while (true) (read from stream and fill queue), ...
-1
votes
0answers
23 views

How to ensure that java threads run in same core ? can we do it programitically in java? [duplicate]

I had started learning multi threading and wanted to know if we can ensure that java threads run in same core ? is it possible to do it programmatically ?
0
votes
0answers
20 views

call uv_write from multi thread, its callback never get called

I've read the tcp-echo-server.c example from libuv, now I'm writing a small multi-thread tcp server based on that. I used the uv_default_loop in the main thread to accept connections, and put new ...
0
votes
1answer
29 views

ExecutorService shutdownNow is not shutting down the JVM

Am learning about ExecutorService introduced in Java 1.5 The following example seems to defy expected behaviour : public static void main(String[] args) throws InterruptedException, ...
0
votes
1answer
28 views

Python Semaphore does not seem to work in Google Colab

I am trying to follow this example limit number of threads working in parallel To limit the number of threads I am working with. When I try this code import threading import time maxthreads = 5 ...
-2
votes
0answers
20 views

How to multithread a for loop with two arrays envolved with ordered return? [on hold]

I'm downloading texts and saving a textual and preprocessed version of each. How do I implement multithrading to it? nortexts = [] pretexts = [] for url in searchurls: nor = extract.normalize(...
0
votes
0answers
18 views

while-loop of Runnable triggers as soon as I set a breakpoint on it [duplicate]

I observed some strange behavior with Runnable and while-loop. I created a server that provides a game loop. As soon as a specific message arrives, the Runnable is supposed to go into this loop. ...
1
vote
1answer
30 views

Speed of Promisified Web Workers

I have the need to compute a mathematically intensive function many (>10,000) times. I thought I'd use web workers in order to alleviate the computational time. I am using a function that creates a ...
0
votes
0answers
21 views

Read 1 line for. each thread

A short time ago I had a simple script to find the panel of a website. I wanted to try again to do it with thread but after a while, I got stuck. My code takes 2 path files to create one with all the ...
0
votes
1answer
35 views

How do javafx multithreading execute sequentially?

I don't know if there are any other good ways to achieve the results I want, thank you. I have a requirement, according to the URL, create multiple webview threads, and execute them in order, such as ...
0
votes
0answers
24 views

Proper ways to use threads in TCL

So I have the following code - #!/usr/bin/env tclsh package require Thread thread::create { for {set i 0} {$i < 1000} {incr i} { puts "hello T1 $i" } thread::wait } thread::...
0
votes
0answers
20 views

How to get return value from a function in Thread class?

I have class of thread that run a function splitFile like this: class readThread (threading.Thread): def __init__(self, numFile, fileName): threading.Thread.__init__(self) self....
0
votes
1answer
51 views

Use multiple threads to update GUI

I'm learning to work with java threads, so I decided to make a simple bouncing balls program. However, the program shows multiple threads but only one takes advantage of the window size, other balls ...
0
votes
0answers
15 views

Spring ThreadPoolTaskExecutor not releasing memory even after calling shutdown

I am using Springs ThreadPoolTaskExecutor in my project for thread Pools. As part of different unit tests, I start these thread Pools, run tests and then shutdown the thread Pools. However, writing ...
0
votes
1answer
17 views

Strange problem in using MPI/OpenMP hybrid programing. Number of OpenMP threads is always 1 in parallel region

System configure: Workstation with two Xeon E5-2620 V4 CPUs. Cent OS 7.3. Openmpi-3.0.1, ifort 2015, gcc 4.8.6, intel MKL. I run an MPI/OpenMP hybrid program on a Workstation. I want to use 1 MPI ...
-1
votes
0answers
53 views

C# - Set maximum execution time for a thread?

I have a thread like this: static void scan() { while(true) { client = server.AcceptTcpClient(); byte[] receivedBuffer = new byte[100]; NetworkStream stream = client....
1
vote
1answer
24 views

How can I reduce time for filtering my article dataset?

I'm trying to filter my dataset which contains nearly 50K articles. From each article I want to filter out stop words and punctuation. But the process is taking long time. I've already filtered the ...
0
votes
0answers
21 views

Slurm job array submission severely underutilizing available resources

The SLURM job array submission isn't working as I expected. When I run my sbatch script to create the array and run the programs I expect it to fully utilize all the cores that are available, however, ...
1
vote
0answers
32 views

Blocking stdin while sleep

I'm making copy of console snake game and have problem with blocking input. I made the agetch () function that processes user input in a separate thread, blocks input when the program is sleeping, ...
4
votes
0answers
52 views

How to Fix the exception received from poco library?

When client create an instant on SenderThread. It can send data to and from. But when client goes for suspend mode and come back from suspend. The last created threads get exception on resume. and no ...
1
vote
2answers
36 views

Does pthread_cond_wait lock the mutex und spurious wakeup

TL;DR I have a homework where i need to implement thread synchronization. During implementation i was concerned if pthread_cond_wait() also locks mutex if it spuriously wakes up and not just if it ...
0
votes
0answers
27 views

How to create ExpensiveGraph

I want to use below code in my application LoadingCache<Key, Graph> graphs = Caffeine.newBuilder() .maximumSize(10_000) .build(key -> createExpensiveGraph(key)); But, I am so dumb ...
0
votes
0answers
7 views

Concurrent access to non-overlapping ranges of RTL_BITMAP

I have a bitmap in my device driver, implemented using a Windows RTL_BITMAP object and manipulated using the RtlXxx bitmap routines (RtlSetBits, RtlCheckBit, etc), that is shared between multiple ...
0
votes
2answers
42 views

Exception thrown when two threads manipulate a list, synchronized via semaphores

Trying to process a list of Order objects with two different threads, but running into the following exception: Exception in thread "Thread 1" java.lang.IndexOutOfBoundsException: Index: 4, Size: ...
-1
votes
0answers
35 views

Problems with thread-pool homework

I'm trying to implement a thread pool for an exercise. Once thread are created they will wait until there is at least one job in the job queue. thus I used a condition variable with a while to wait. ...
-1
votes
1answer
37 views

only 1 thread possible with boost asio on machines with many cores

We have very weird problem, we manage to create very small somehow reproducible(on some PCs) example: main.cpp Dockerfile This code do absolutely nothing useful it only logs few lines, but these few ...
1
vote
0answers
27 views

How to fix 'multithreading problem' in python in rasberry pi

I couldn't find out what might be the problem with the multithreading program that I have written in python in raspberry pi 3 for the object recognition. The code is running on the raspberry pi 3 ...
2
votes
3answers
66 views

Is it necessary to make pthread_mutex_t variable volatile?

In java we normally make the lock variable final static so that only one copy of it exists (Though I remember reading that even static variables can be duplicated into call stacks of two methods!) ...
4
votes
0answers
54 views

How to speed up PowerShell portscanner

For various reasons, I started to write a PowerShell portscanner, not least to start learning it. First iteration used Test-Netconnection. This seemed as if it would be too slow; so I went one level ...
0
votes
0answers
21 views

How to can apply multithreading for a for loop in python [duplicate]

I am new to python , One command in my code is taking long time to execute and I need to execute it multiple time according to a list.I want to implement mutithreading here .In below code getcmdresult ...
0
votes
1answer
80 views

Writing in file from shared buffer missing data and program crash without cout

I am making a program using threads and a shared buffer. The two threads run indefinitely in the background, one thread will fill a shared buffer with data and the other thread will write the content ...