Questions tagged [single-threaded]
Single threaded as opposed to multithreading defines a code section, object or application that can run only using and allowing a single thread.
203
questions
0
votes
0
answers
44
views
Single-threaded concurrency in Python
I am having difficulty understanding concurrency, single-threadedness and Python's threading. Is it possible to have single-threaded concurrency model in Python? How does such a model works
0
votes
1
answer
84
views
Can someone explain JS Event Loop?
So I kind of understand the JS event loop, but still have a few questions. Here is my scenario and a few questions.
So let's say I have these functions:
function1 - reads an absolute huge file.
...
0
votes
0
answers
54
views
Is there any solution to diminish the time of the VBA loop below considering VBA is "by default" single threaded? It's a sum loop
The idea of the loop is to iterate for an n number of foods, calculate the calories of each element and calculate the total sum of all (it's a sum loop). The loop has an (n) time complexity, I believe....
0
votes
1
answer
61
views
Single thread and asynchronous confusion
I've read various articles and similar questions, and I know that the two concepts are different, but I don't seem to know the correct answer.
I understood that thread is in terms of number of workers,...
0
votes
1
answer
111
views
Handling multiple requests with express
I have a background with Java and I am relatively new to node. I am trying to understand node in relation to the fact that it is single threaded, but can still handle multiple requests at the same ...
0
votes
0
answers
79
views
How to skip a queue item in a single thread?
I have queue maintained by a single thread. The thread will do some operations on each item of the queue in turn. I want the single thread could skip certain queue item and go on for the next item ...
0
votes
0
answers
52
views
Problem updating a resource array due to node single thread concurrency
Tables:
users
user_category
categories
user_id (PK)
user_id (PK)
category_id (PK)
name
category_id (PK)
name
I'm having problems with concurrency on node, I'll describe an example to reproduce the ...
0
votes
1
answer
19
views
Can/should Thread Switching be controlled?
Forgive me - I'm not a hardware tech, just an app user.
Background: I've observed that when I am running one large process in a singlethreaded program (OCAD, QGIS, usually R, etc), I can see that one ...
1
vote
2
answers
173
views
Node JS Concurrency Handling Coding Interview Question
I attended a NodeJS coding interview. Got below code which executes asynchronously from different browsers(to be assumed). Our solution needs to lock the execution of function if the update by ID is ...
0
votes
0
answers
56
views
Single / multi threaded Websocket Chat
I was curious if a multithreaded chat server can broadcast messages to other clients.
I know that NodeJS is single-threaded and Socket.io is a good example for that. When a client wants to broadcast a ...
0
votes
1
answer
190
views
PHP application slow processing on AWS EC2 when heavy traffic hits
I have a cloud-based application written in PHP 5.6. It is a supermarket application that has traffic in some specific hours. In those peak hours, when large traffic hits across multiple supermarkets, ...
1
vote
1
answer
134
views
How to Perform Concurrent Request-Reply for Asynchronous Tasks with ZeroMQ?
Intention
I want to allow a client to send a task to some server at a fixed address.
The server may take that task and perform it at some arbitrary point in the future, but may still take requests ...
0
votes
1
answer
370
views
How can I reuse same HttpClient Connection in my Single threaded Java Client Application?
I am working on one Single threaded java client . It is making One HttpClient connection to hit some API's. I want to use same connection object to hit another set of API's after sometime. It is ...
2
votes
0
answers
72
views
What is the effect of heavy computation on `Timer.periodc` ( or `setInterval`)
I was wondering what is the effect of heavy computation on Timer.periodc which often happens when making bots doing at an heavy task and at the same time running a job at a regular interval.
So I made ...
0
votes
0
answers
19
views
problem with setting loading animation class during sync JS work [duplicate]
I'm working on visual version of my sorting algorithm and I would like to show to the user a loading animaton during the sorting itself by JS. But the problem is that JS behaves weird then. It ...
0
votes
0
answers
44
views
I'm Creating Worker with node Cluster module now, I need to set load balance
My question is, now that I need a load balancer something else, or this Worker that I create according to the CPUs Core size works perfectly well in the node app.
const express = require("express&...
1
vote
0
answers
208
views
Why we need async Callback in Node JS Since Event Loop offers Worker Pool to handle expensive task?
I was studying how Node JS improves performance for multiple concurrent request! After reading couple of blogs I found out that:
When any request come an event is triggered and corresponding
callback ...
0
votes
2
answers
303
views
Java - Allow one thread in a method without waiting
I've a situation where I need to implement a thread safe method, The method must be executed by only one thread at a time, And while the method is being executed by a thread, all other threads trying ...
1
vote
0
answers
111
views
How to throw Exception from a method and prevent multiple threading
I have a question which I need pointers to how best to solve it.
So I have a Booking Class with 2 methods:
StartBooking();
GetBookingStatus.
These are the conditions to execute this function:
When ...
0
votes
0
answers
113
views
Nodejs / ExpressJs - Making parallel api request to do synchronous / asynchronous job
I know that javascript is single threaded, meaning only one operation runs at a time. Now consider the following scenario:
Scenario 1:
I have a nodejs/express server running on port 5000, it has an ...
0
votes
0
answers
155
views
Rust mutable references in a single threaded environment
I have a very specific question regarding mutable references in a single threaded environment and will try to explain that as clearly as possible. I have a service running in a single thread which has ...
3
votes
0
answers
76
views
How can I access the Standard-input with a Socket in C#?
I am trying to manage a client side in a chat program.
So the client should get the input from the keyboard and send it to the server.
In the meantime, it should be able to recieve masseges from the ...
1
vote
0
answers
219
views
Use own TCP layer implementation with QuickFIX/J
My codebase relies on an internal TCP layer implementation which does TCP session multiplexing using a non blocking selector pattern (java.nio). This means I can create a single threaded app that can ...
-1
votes
2
answers
446
views
Rust: Safe single-threaded TCP Server
is it possible in pure rust to write a single-threaded TCP Server?
In C I would use the select syscall to "listen" to multiple sockets.
I only find solutions where people use unsafe to use ...
1
vote
2
answers
109
views
how event loop exactly executes code in 2 seconds if the code is larger and call stack is not empty?
many explanations talk about call-stack being empty, but I don't get it, if we set a timer for 2 second and executes the code in an asynchronous manner, what if I have a code with run time of 10 sec ...
7
votes
3
answers
279
views
In javascript, why doesn't the below code exit the loop?
let a = true;
setTimeout(() => {a = false}, 1000)
while(a){console.log(a)}
1
vote
0
answers
61
views
Do javascript code blocks run atomically relative to the single thread?
When I am developing in Typescript and I have a variable:
const fn: undefined | () => void
and write this:
...
if (!fn)
return;
setTimeout(() => fn(), 0);
...
Typescript will complain, ...
2
votes
2
answers
632
views
Flutter update progress in compute method
I have to save many images to the device to make videos.
As saving multiple images takes so much time and resources, I use compute to save images.
I want to show the progress in saving images so that ...
0
votes
1
answer
75
views
Does all single threaded software run on the main core/thread? [closed]
I'm planning to run for example 10 instances of a single software - single-threaded game server.
They will run on a server machine(not VPS) on plain Linux Ubuntu(console version).
My question is, if I ...
-3
votes
1
answer
423
views
What makes asynchronous single threaded java code asynchronous
So we are currently working on an app in java and a colleague introduced me to asynchronous programming and it doesn't matter how much I research it, to me it seems that is synchronous.
So the main ...
3
votes
1
answer
2k
views
In Java, is there a way to check if Runnable is completed in single thread?
In Java, I need to get two parameters, Runnable and Delay in milliseconds, and need to run the Runnable in the delay time. This needs to be run in single thread, and if the method is invoked with ...
1
vote
1
answer
124
views
Does setTimeout has to be a API provided by broswer? [duplicate]
I'm trying to understand the APIs provided to JS engine by the browser.
Since JavaScript is single threaded, it has to outsource the timer to the browser so that the code execution is not blocked.
So ...
0
votes
1
answer
147
views
Corda FlowLogic Behaviour in a scenario - What is the relevance of threads here?
I was trying to understand the actual flow of flow-logic and sessions.
Consider a scenario in which there are 3 party nodes A, B and C. At the very onset, A initiates a transaction with B, but B was ...
2
votes
1
answer
787
views
Run all tests in same thread NUnit
I have some tests that do some write-operation on a database. I know that´s not really unit-testing, but let´s leave that asside.
In order to enable every test to work on a clean workspace, I rollback ...
5
votes
1
answer
2k
views
Node.js multithreading: What are Worker threads and how does it work?
I always believed that JS was a single threaded language which makes it inefficient for CPU intensive tasks. I recently came across worker threads and how it solves this inefficiency problem by ...
1
vote
3
answers
115
views
How do I run something inside a class concurrently (in single threaded platform)?
I have to write a class that implements the given interface below. When I call the start function it should starts counting every 1 millisecond and when I call the stop function it should stop ...
0
votes
1
answer
510
views
Is JavaScript single threaded? [duplicate]
As it is obvious that nodeJs is single-threaded. But JavaScript as a language is also single-threaded?
1
vote
1
answer
110
views
Will my server be able to run only one client if its a single-threaded process. If yes, why?
I have googled decent enough to understand threads and processes. One thing I am confused is about single-threaded process.
The scenario is the Server-Client application process where each client is ...
0
votes
1
answer
799
views
Is there a way to run Redis server on multiple nodes or multiple cores of a CPU?
I am currently working on running a deep learning model using Redis server, and for its optimisation, I was wondering if there is a way to run Redis server on multiple nodes, since redis is single ...
0
votes
1
answer
442
views
Can I configure a Dataflow job to be single threaded?
I was trying to configure and deploy a Cloud Dataflow job that is truly single threaded to avoid concurrency issues while creating/updating entities in the datastore. I was under the assumption that ...
0
votes
2
answers
89
views
What is the definition of "cold spots" vs. "hot spots" in program runtime analysis? [closed]
In a blogpost on https://discourse.ubuntu.com the performance weakness of Gnome-Shell is explained as being caused – not by obviously detectable "hot spots", but being caused – by "cold spots":
"...
1
vote
0
answers
143
views
Python multi-core slower than single-core
I'm trying to compare single-threaded vs multi-threaded performance and coded a Prime Number checker.
It's just two functions, one running in normal single-thread mode, and the other uses the python ...
3
votes
1
answer
721
views
sbatch+srun: Large amount of single thread jobs
Hello friendly people,
my question is rather specific.
For more than a week, I am trying to submit thousands of single thread jobs for a scientific experiment using sbatch and srun.
The problem is ...
3
votes
1
answer
37
views
Why is the audio executed after the prompt?
function myTimer() {
randint= Math.floor(Math.random() * 10)+1;
randstimuli=gorilla.stimuliURL(dict[randint]);
var audio = new Audio(randstimuli);
audio.play();
var start=Date.now()...
1
vote
1
answer
245
views
Can two piece of code be run at the same time in node.js?
As I understand the non-blocking concept this could happen. But the one threat architecture of node.js made me doubt about it.
Let's say I have two endpoints on my HTTP server:
app.get('/one', () =&...
1
vote
1
answer
3k
views
What happens when multiple requests come to server
I am not sure about this topic. I'll try to explain that with examples.
Let's suppose, I have a payment method on php webserver. Firstly the method checks are there unpaid orders. If yes, send ...
0
votes
2
answers
173
views
How do I add a list of programs currently running on java socket server?
I have set up a Java socket server. I want the client to be able to input "Running Processes" which will cause the server to print all of the programs running on the server. The server code looks ...
0
votes
1
answer
381
views
Fetching large amount of data with React native
was working on a project that for some of the users, we need to fetch a large amount of data. It seems that it's fine on the simulator, but it can be pretty slow when running one a real iOS/iPhone ...
-2
votes
1
answer
76
views
How Node handles the concurrent request and how we can handle these concurrent requests one by one in code
I am doing something in the function(some asynchronous work) for the first request but at the same time a few more requests came, now my thread was working on the function(some asynchronous work) but ...
0
votes
2
answers
55
views
Why is Bootstrap Spinner Unusable in Compute Intensive Context
I am aware Javascript is single-threaded. However I do not understand why the following code does not show/hide a spinner before/after a compute-intensive task.
Code outline:
showSpinner();
...