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).

-1
votes
0answers
30 views

Using the same pointer for reading and writing of data with multiple threads

I am capturing images of a RGB camera with unity (C#). Then I send each frame to OpenCV in form of a pointer to the bytearray of the image. There, I am reconstructing the image with the pointer to ...
0
votes
0answers
19 views

Thread safe copying of a deque without blocking append

I'm trying to create a circular buffer in python. My best implementation is by using deque with fixed length. (basic implementation) class RingBuffer(object): def __init__(self, size): ...
0
votes
1answer
41 views

Does callback are received on main thread only?

I am creating a process, which on running create a child thread also. At some point child thread register callback of another library. when i check that callback is invoked on main thread. Can anyone ...
0
votes
1answer
34 views

Filling and saving shared buffer between threads

I'm working with an API that retrieves I/Q data. Calling the function bbGetIQ(m_handle, &pkt);fills a buffer. This is a thread looping while the user hasn't input "stop". Pkt is a structure and ...
0
votes
2answers
24 views

What advantage will multithreading give in presence of GIL?

If in the presence of GIL, all subtasks performed in a multithreading program occur sequentially, then it is equivalent to single threaded program. Why were multithreading packages (multiprocessing....
0
votes
0answers
11 views

Async annotation and parallel processing

Here is the environment first: A service publishing high amount of messages to a queue. This is a Spring boot application running in a container and I have access to it (means it is possible to ...
3
votes
2answers
65 views

Is it safe to read and write to an array at different positions from multiple threads in C with phtreads?

Let's suppose that there are two threads, A and B. There is also a shared array: float X[100]. Thread A writes to the array one element at a time in order, every 10 steps it updates a shared variable ...
2
votes
2answers
12 views

How can I import thread package in Python 3?

I want to import thread package in Python 3.6. But this error is occurred: import thread ModuleNotFoundError: No module named 'thread'
1
vote
2answers
21 views

how to start first thread complete to after second thread start

Am using some method i need to some method complete to start to another method so that am using thread function, How to start one thread follow by to second thread start? Thread thread1 = new Thread(...
0
votes
1answer
29 views

What happens when multiple threads are writing to a single table in mysql?

I am facing a situation where multiple threads are trying to insert data to the same table in mysql, **Will it be OK without explicit handle it? ** I am afraid every thread is inserting, some thread ...
0
votes
0answers
9 views

Need help regarding attacking a thread leak issue

So we have created a new Netty4 server and are generating load against it. The number of host threads is growing as a function of the TPS to the server. Moreover once the load test is over, the host ...
0
votes
1answer
30 views

Vert.x Thread Naming - “vert.x-worker-thread-…”

I am making a blocking service call in one of my worker verticles that logged a warning. This was "addressed" by increasing the time limit, but, I am more curious about how to read the naming of the ...
0
votes
0answers
32 views

How to properly synchronize Threads in ActionListener?

I'm working on a program that uses two Threads to display Date() on a JArea at different time intervals. "When you click "GO" the thread starts and "GO" changes to "SUSP" and vice versa." I'm not ...
0
votes
0answers
27 views

pthreads mutex: protect member of a struct

Given a mutex which protects a struct I would like to protect a member of the struct mystruct named 'tasklist`. Will the use of the mutex in the following scenario be enough? Code: ...
1
vote
0answers
30 views

How to implement multithreading in a Java ray tracer

I'm writing a ray tracing program in Java and have implemented multithreading using Runnable interface. Each thread renders a portion of the 800 vertical lines. When using two threads, they will ...
0
votes
0answers
16 views

How to make decibel meter in Kotlin?

I'm learning Kotlin and i want to calculate how noisy is outside only in one activity. I've tried this topic : Decibel Meter using Media Recorder . But i am confused about threads. I want to stop the ...
0
votes
1answer
36 views

Wait for executor for it's threads to finish by executor submit [duplicate]

UPDATE: I Fixed it with this code(Works only if you know the total tasks count, My case) int totalThreads = 0; int finishedThreads = 0; private void checkExecutorFinished() { if(finishedThreads =...
0
votes
0answers
15 views

How can I do other task while message box is still open? [duplicate]

I have a simple Swing window with two buttons (Button A, Button B). Each button shows a message box when they are clicked. Problem is when I click on Button A and its message box shows, I cannot click ...
1
vote
1answer
42 views

Does synchronized block cause all write cache to flush?

I am interested in how synchronized works in sense how/when it flushes writes from local caches. Lets imagine I have following code: class Scratch1 { int counter = 0; Scratch1() throws ...
-2
votes
3answers
41 views

Can I write to a specific index of a List, if I know no other thread will access that index without a lock

I have 4 threads that each have their own loop and they access a List that contains a delta time for each thread. Since there are 4 threads in this example, there will be 4 items in the List. Can ...
0
votes
0answers
26 views

synchronized block on Object.class in java?

Consider the following code: synchronized(Object.class){ ... } What would it do? I'd like to use it for "implementing atomic" in java, I'd expect that this synchronized block will block all other ...
1
vote
1answer
39 views

Consecutive parallel computation with very low workload per invocation

Lets suppose i want to compute the methods A and B in the following example in parallel: while (true) { int state = NextState(); int a = A(state); int b = B(state); ImportantMethod(a, b)...
0
votes
0answers
32 views

OMP does not parallelize sections on Visual Studio 2015

I am developing a mex-file with C++ and OpenMP API. I am trying to execute different sections on different threads, however, they seem to be executed within the same thread. I wrote this example: ...
0
votes
0answers
17 views

access to SeismicCube from another thread

i'm using thread to launch on background a function using SeismicCube public class JobSetup { public SeismicCube cube; } public void Function1(SeismicCube cube) { var jobSetup = new ...
2
votes
1answer
47 views

Does this unique_lock in dtor serve any purpose?

Ran across this destructor in a codebase I am debugging. ManagerImpl::~ManagerImpl() { // don't go away if some thread is still hitting us boost::unique_lock<boost::mutex> l(m_mutex); } ...
0
votes
2answers
24 views

Why does the property edited value persists?

By reading a question about concurrency on a collection made by another user, I started trying to write my own threadsafe list class. After doing that I made a testcase, which i used to try and it ...
2
votes
0answers
43 views

Starting mupltiple threads and collect the results

I have an Interface for searching in some subsystems gathered by an ENUM. The Interface looks like this: public interface ReferenceController { public Map<String, ReferenceElement> ...
-1
votes
0answers
54 views

Why my WinForm is spending so much time to precess threads of ping?

I have a Winform that can ping a range of IP address chosen by the user. The ping's answer is written in different richTextBox according to the IP address. I can choose to ping several range of ping ...
0
votes
0answers
14 views

How to gather and sort logging output from multithread processes

I have a CLI tool written in Python that operates on a bunch of files and makes use of multithreading for small file operations. While the parts executed as threads are only subsections in a longer ...
1
vote
0answers
24 views

SignalR Hub broadcasting from custom function triggered by Hub method

How can I run SignalR Hub for long running process in case like this? I want to broadcast data from async IoT Hub receiver to all clients connected to hub, but i want to have only 1 thread running and ...
0
votes
0answers
26 views

Increasing RES value for a multhreading C app

I have developed a 2 thread C app which shares information between threads with a queue and a mutex to protect write or reads. Both threads are an infinite loop with the application inside. I have ...
1
vote
2answers
49 views

How to make a thread wait for a specific condition

There is a thread calculating prime numbers and adding them into a collection. Now there are other Threads which will perform a bool isPrime(long n) method. This method will just look into the ...
0
votes
0answers
41 views

Is it possible to do some work in one thread and make tkinter Progressbar to run in another (mainloop) simultaneouly?

I would like to solve the following task in Tkinter : I have function which read from file. do some stuff and then write results in another file, I need Tkinter.ttk progressbar to run while the ...
0
votes
1answer
30 views

I want to pass large data from work manager to my fragment without using room

I want to pass the list that i get from work manager api request to my fragment so I can update adapter of recyclerview. I don't want to use Room since the list is larger than 10 Kb but instead I'm ...
1
vote
0answers
12 views

How can I have a global object that is thread-safe in a Flask application? [duplicate]

I'm trying to build a REST API with Flask that's supposed to respond based on a statistical model implemented with pandas and numpy. The model is a constant for a set number of days, after which it ...
3
votes
1answer
50 views

Output thread IDs as seen by debugger

I'm developing a multi-threaded C++ application using GCC 4.4.5 and GDB 7.2. At the moment, I have four threads. Each one interacts with a CAN bus in one form or another, either reading, writing, ...
1
vote
2answers
39 views

Is there a safe way for a quick exchange of data between threads?

I'm setting up an application that reads data from a load cell and, in real time, based on the data read, interrupts the thrust of a motor. It is essential to have a high frequency reading from the ...
0
votes
1answer
30 views

multiple volley requests at same time

I need to send 4 http requests at same time and wait until all of them finished (i'm using volley) I've tried to send them separately in 4 threads and use thread.join but it seems that onResponse and ...
2
votes
0answers
41 views

How to handle java.util.concurrent.RejectedExecutionException in android

I am getting java.util.concurrent.RejectedExecutionException exception while trying to load images in ImageView.This is not occurring every time but occurring in sometime.I know why the problem ...
1
vote
0answers
22 views

How are Threads allocated to handle request ? especially If request are about 10K per second

I have been asked in an interview that, what kind of optimization you'll perform to handle about 10K request per second. What kind of strategy you'll comply while developing controllers.
2
votes
4answers
38 views

could there be a racing situation in the following code?

We know the destructor code below is supposed to release the control block if this is the last smart_ptr pointing to the resource being managed. Is it possible that we have a racing problem between ...
0
votes
1answer
60 views

Simple non-blocking multi-threaded tcp server

I'm studying C++, and this weekend I started to play around with sockets and threads. Bellow is a simple multi threaded server that I'm making based on some tutorials. The issue that I'm facing is ...
0
votes
0answers
29 views

How to fix '(sqlite3.ProgrammingError) SQLite objects created in a thread can only be used in that same thread.' Issue?

I'm utilizing Flask and SqlAlchemy. The database I've created for SqlAlchemy seems to mess up when I try to run my website and will pop up with the error stating that there's a thread error. I'm ...
0
votes
1answer
43 views

How to properly use wait() and notify() in Java? (HiveMQ Client) [duplicate]

I've writing a program using HiveMQ Client (an MQTT Open source implementation in Java) that involves using two multithreaded clients. One client is designated as the publisher and the other as the ...
1
vote
0answers
69 views

Why would adding System.out.println make threads run faster?

I was was trying various methods of making a large computation run in parallel. This worked as expected, except when explicitly creating and starting Thread instances, which was much slower. I added ...
0
votes
1answer
28 views

Is there a good solution for a threaded application that can be paused and unpaused externally in java?

I have a problem with figuring out a good way to write an application that runs on its own thread. One should be able to start and stop it and while its running to pause and unpause. public abstract ...
0
votes
0answers
18 views

Crash while adding UIImages to array: UnsafeMutablePointer.deinitialize with negative count

So this is my source code. I'm trying to adding UIImages to an array datasource and on completion, I'm reloading a collectionview. But every once in a while, the app crashes at line self....
-3
votes
0answers
29 views

i want execute a script even the game was closed

I've made a game in Unity, and I want to execute a C# script that show ads even when the game is closed. I create a checkstate function that reads turnon from the json. If it's equal to 1, then show ...
0
votes
0answers
23 views

Is the common ForkJoin pool system wide or per JVM Instance

I want to know if the forkjoinpool.commonpool() is a OS system wide share thread pool or a per JVM instance shared thread pool?
-1
votes
0answers
27 views

Dependency Injection and Threads : Segmentation fault or Sig abort, how I can use a shared pointer?

I have the following classes and functions: #ifndef HTTP_NETWORK #define HTTP_NETWORK #include <string> #include <arpa/inet.h> //Dummy Value to be changed #define MAXPENDING 5 class ...