Questions tagged [multithreading]

Multi-threading related questions including technique, structure, and safety issues.

Filter by
Sorted by
Tagged with
2
votes
0answers
502 views

How to dispatch these functions in Objective C to not lock Main thread?

There's a large shared object (kind of OpenGL context) in my project. It is accessed from multiple threads. To ensure only one thread at the moments is using SHARED_OBJECT, mutex (kind of ...
1
vote
0answers
138 views

How to decouple a message broker and its message handlers?

Project description: I have a nodejs project where I try to build a bluetooth mesh like network, each node consists roughly of 4 parts the frontend part, the message broker, a bluetooth client and a ...
1
vote
1answer
705 views

Multiple API calls potentially spawning multiple Websockets - Threading vs Async

I am designing a program with the flow as outlined below. Note, these are all network calls, there is no system I/O (hard drive). Initially, multiple independent API calls need to happen - they don'...
0
votes
1answer
135 views

Mqtt multithreaded Java app

I have a Java app which acts like a command server for other devices and communicated with them via MQTT. I want to add a new functionality and don't let my sender class (implemented as a thread) send ...
5
votes
2answers
16k views

What construct do I use to guarantee 100 tasks are running in parallel

I was trying to create an integration test for my service where 100 clients would connect, login, send request, and log all responses for some configurable amount of time. I was build a class for ...
6
votes
1answer
205 views

Immediately awaiting an asynchronous call [duplicate]

While working on an inherited project, I noticed the original dev(s) created many asynchronous functions that never seem to take advantage of being, well, asynchronous. For example: // The async ...
3
votes
1answer
1k views

Enhancing the quality & performance by opting for multiple tasks vs single task?

I'm trying to improve the performance, code quality and just make it better in terms of practice overall. I have a server for a game that managers all users connected as well as things like objects ...
0
votes
2answers
5k views

One thread for all database operations or one thread for each db operations?

I am working on a server application that should handle many requests. There is one thread per each request and each request has a Database operation. Creating connection for each request and doing ...
1
vote
2answers
263 views

Good practice to store runtime data

Cheers guys, I am quite new to C++, however, I have some years of experience in programming and I am open for challenges :-) Currently, I am designing a "small" scientific program to perform some ...
1
vote
2answers
2k views

How do I get a program designed to run continuously (converting data on a Serial COM port) to exit?

Problem Statement I'm writing a C# console program that takes binary data coming in through Serial COM1, converting each byte into ASCII hex, and then outputting those HEX characters out through ...
0
votes
1answer
157 views

Does placing an httpd server in front of a Vert.x application defeats Vert.x's purpose?

I'm watching a talk on Vert.x (not in English) and they say that "the whole architecture needs to be asynchronous from beginning to end", and cites as an example of what not to do putting an Apache ...
5
votes
1answer
1k views

Alternative to Actor model

My main experience working with multithread environment was using Scala, so if I had an object that was concurrently updated by multiple threads I always used Akka. Now working in Java environment I ...
0
votes
2answers
431 views

Updating an object without locking or corruption in Java?

Let's say you have a multiplayer game where different player threads are constantly updating the same game state. How do you best update this state without suffering locking bottlenecks or corrupting ...
3
votes
1answer
71 views

How do deal with an IM bot that needs to run minutely tasks while also waiting for commands

I am writing a bot for Matrix using Ruby which allows users to subscribe to RSS feeds and when a new item shows up on the feed it gets sent to the room. The problem I have come up against is how do I ...
0
votes
1answer
2k views

Does Web Socket block thread while keeping connection as regular http connection does?

Let's take Spring web socket (with tomcat) for example. Does Web Socket blocks thread while keeping the connection between server and client? (For example, connection can last 2-3 hours). ( Does web ...
0
votes
2answers
240 views

State ownership cover everything for a class to be thread safe

As mentioned by Java_author, When defining which variables form an object's state, we want to consider only the data that object owns.... In many case, ownership and encapsulation go together—...
-1
votes
2answers
603 views

Straight line coding - How multithreading simplify asynchronous workflow?

Java author mentions: Threads can simplify the development of complex systems by turning complicated asynchronous code into simpler straight-line code. Again the book says: Threads make it easier to ...
2
votes
2answers
450 views

Module pattern in C with threading - where to control threads?

So I'm working on a growing C program in a Linux / POSIX environment, and I've run into an area where I'm not quite sure how to proceed. Basically, I'm using a module pattern to develop my code for ...
0
votes
2answers
530 views

What is an effective design pattern for 'fan-in' from multiple task threads into a single UI thread?

In many applications the 'UI thread' is special and framework UI updates must be dispatched from this thread. However, in order to avoid locking the UI slow tasks are executed in background threads ...
3
votes
2answers
982 views

How do I design a buffer for a console?

Problem I have a graphical console widget that receives output from an interpreter. Unfortunately the console is not fast enough to paint the output in real-time. So I had to implement a buffer(FIFO ...
1
vote
1answer
256 views

Global rate limiting to hit an API from workers that live on multiple machines?

I have to design a system where an API has to be hit to get the meta info about some data. We have multiple workers, that take jobs from multiple queues. Now the API has a rate limit of say 500 per ...
2
votes
2answers
149 views

How is it possible to have limitless availability of threads while only having a finite number of physical processing units?

So I'm having trouble understanding the relationship between threads (software) and processor cores (hardware). Basically my understanding of a processor core is a unit that deals with commands and ...
0
votes
2answers
754 views

How to design configurable validations to import Excel files?

I have a requirement where I need to validate excel file before importing into application. Excel file will have around 15-20 defined columns. And we are having around 200-250 rules to validate the ...
12
votes
5answers
3k views

how many cores should I utilize for calculations? #cores or #cores -1?

I have a large calculation to do. While I can utilize all cores, I thought is there any reason to leave off 1 core and not to utilize it? (calculation cpu only no IO). Or am i underestimating the OS ...
0
votes
1answer
134 views

System design for a client server problem

I am trying to design and implement a solution for the following problem I am facing in one of my projects. There are n (say 30) clients that send me data points of the form {timestamp, object}, ...
3
votes
3answers
269 views

How to simulate living things in software [closed]

I was thinking about creating a simple game/simulation where cars drive around in a city as part of a pet project. That made me think how I would simulate these individual cars in a simulated world. ...
1
vote
1answer
537 views

TPL parallel for each or custom queue for multithreaded data processing

I'm looking to do the following for 1000s of items: 1) get time series data for an item from file 2) calculate mean and standard deviation 3) calculate final calculation using mean and standard ...
3
votes
2answers
1k views

Threads - When to use barrier?

Using python syntax, threading.Barrier(NUM_THREADS) establishes a control point and all participating threads block until all of the participating “parties” have reached that point. It lets threads ...
1
vote
2answers
2k views

What are reactive streams and what's so special in them?

I browsed Wikipedia and encountered a new feature of Java 1.9: Reactive streams. Unfortunately, the linked Wikipedia page doesn't help much to understand what those reactive streams are and what's so ...
5
votes
1answer
2k views

When to use coroutine over generator?

Pipeline processing of data can be done either, using generators only Example generator in pipeline: def grep(source, pattern=None): patternObject = re.compile(pattern) for line in source: ...
21
votes
4answers
7k views

Why coroutines are back? [closed]

Most of the groundwork for coroutines occurred in the 60s/70s and then stopped in favor of alternatives(e.g., threads) Is there any substance to the renewed interest in coroutines that has been ...
-4
votes
1answer
77 views

Appropriate design for mutlithreaded asynchronous server app?

I have a three layer application with your basic client layer, middle layer, and database layer. The middle layer is intended to take requests for work and data from the client, process it, and then ...
-5
votes
1answer
884 views

Feature of CPU needed to run Javascript fast

This is more of a Computer Engineering question, but what is the feature of a CPU to run Javascript fast? I use to access the internet with an AMD Phenom II with 6 cores and I could almost have as ...
65
votes
3answers
38k views

How does a single thread run on multiple cores?

I am trying to understand, at a high-level, how single threads run across multiple cores. Below is my best understanding. I do not believe it is correct though. Based on my reading of Hyper-threading,...
4
votes
1answer
630 views

Why is it a bad design to designate one thread to send data on a socket and the other to receive data?

I posted a question on SO whether two threads can simultaneously execute a send() and a recv() on the same socket. I was told that while they could, implementing this was an example of a very poor ...
0
votes
1answer
94 views

Performing multiple actions on each row of table from many databases

I am working on a project that manages employee payrolls using php (no frameworks). This application consists of clients (with their own databases). Each database consists of the client's employees ...
2
votes
1answer
78 views

Running daily tasks on backend server alongside other tasks

So I have a Google Cloud AppEngine server which has 2 main jobs. Every Day at 00:00, download lots of data (Firebase/Async), process it, and send out notifications via HTTP, interact with ...
4
votes
3answers
355 views

Unit testing thread abstraction

Being portable C++ code, our project has an abstraction layer over threads. This layer has unit tests. This includes tests like that Thread::sleep(100) wakes up in 130 ms, that CondVar::notify() wakes ...
3
votes
3answers
781 views

Make multithreaded program asynchronous

There is an application that processes TCP/IP requests according to some logic, and pretty always it connects to DB. Architecture is very common: one client -> one processing thread -> one DB ...
8
votes
1answer
5k views

Why use ExecutorService for long-running thread?

I want an object that will spawn a daemon thread that will continue to run for the lifetime of the process. Let's say, just for the sake of the argument, that it's a thread in an embedded system, and ...
-1
votes
1answer
477 views

languages with native thread support

I am investigating ways of making my bundle of python network-requesting processes more efficient and became interested in the likes of Go and Julia for their apparent strong concurrency support and ...
4
votes
1answer
24k views

Correct usage of async/await and Task.Run()

I am developing an application that will read excel files from disk and then process tests based on the data in the files. In order to keep the user interface from locking up when loading files and ...
0
votes
1answer
4k views

Multithreaded C# MVVM Application Architecture

I have an application built in C# using the MVVM pattern that will have 40-50 different tests that need to be run. I want to show each test as a list item with a progress bar of how far each test has ...
-1
votes
1answer
164 views

How is the thread identification counted and will it recycle numbers

I was wondering how the Thread identification works in .NET. Does it always +1 the last number and never look back? or if thread 5 stops and a new thread is created will it use 5 as it is now free to ...
0
votes
1answer
625 views

When is it More Appropriate to Use Java Thread instead of Quasar Fiber?

I've browsed around about Quasar fiber yesterday and it seems that it's more lightweight than Java thread based on the following demo. My questions would be: Are there any scenarios that thread is ...
0
votes
3answers
584 views

Is a data structure used only in a single thread always safe?

I had a conversation with a few co-workers and the concept of thread safety for a data structure came up. In this example, we have 2 threads: a main thread and a background thread. For the following ...
7
votes
2answers
5k views

Separate Thread Pools for I/O and CPU Tasks

I've been puzzling over a good implementation for this for a while. I have a program that does a long-running I/O operation (downloading a file) and a long-running CPU operation (parsing its contents)...
0
votes
1answer
227 views

Why the distributed process clocks in a distributed system using Lamport clocks will eventually converge?

Basically the lamport clock helps the host to order the events rather than the exact time. How does all the logical clocks end up being converged in the long term?
3
votes
0answers
697 views

Multithreading in Android

Looking for resources that teach multithreading in Android and list best practices. I want to do some image processing on the preview frame of the camera (already have this part set up) but want to ...
3
votes
1answer
2k views

Is the Fork-Join framework in Java broken?

Just finished reading this article which claims the Java Fork-Join framework is a bad fit for almost any realistic task. He seems to being up some good points but I don't feel qualified to say if he's ...

1 2 3 4 5 12