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.
210
questions
75
votes
6
answers
4k
views
Why isn't setTimeout cancelling my loop?
I wondered how many times can a JavaScript while statement (in Chrome's console) can increment a variable in a millisecond, so I quickly wrote this snippet directly into console:
var run = true, i = ...
74
votes
4
answers
124k
views
Single-threaded apartment - cannot instantiate ActiveX control
I need to get information about applied CSS styles in HTML page. I used AxWebBrowser and iterate IHTMLDOMNode. I'm able to get all the data I need and move the code into my application. The problem is ...
52
votes
2
answers
4k
views
What happens if an alert window is shown during an ajax call?
I was just wondering what could happen if, while an ajax call is being executed, an alert is prompted to the user, in the browser window.
Let's say, for example, that I have an ajax call
$.ajax({
...
25
votes
1
answer
13k
views
Node.js server with multiple concurrent requests, how does it work?
I know node.js is a single threaded, asynchronous, non blocking i/o. I've read a lot about that. e.g PHP uses one thread per request but node uses only one thread for all, like that.
Suppose there ...
24
votes
1
answer
7k
views
How are the Event Loop, Callback Queue, and Javascript’s single thread connected?
GENERAL GOAL
I’d like to know how the following pieces of a javascript environment interconnect as a system.
Javascript Engine
Event Loop
Event Queue
We can limit this to a browser environment ...
16
votes
2
answers
29k
views
Windows service OnStop wait for finished processing
I actually develop a Windows service in VS 2012 / .NET 4.5.
The service is following the scheme of the code snippet below:
Using a timer
Executes some desired operation every couple of minutes.
...
15
votes
3
answers
19k
views
Single- vs. multi-threaded programming on a single core processor
Can someone please explain if there's really any advantage to writing a multi-threaded piece of code that runs on a single processor with a single core? E.g., a method that processes document pages ...
12
votes
3
answers
13k
views
why Redis is single threaded(event driven)
I am trying to understanding basics of Redis.
One that that keep coming everywhere is, Redis is single threaded that makes things atomic.But I am unable to imagine how this is working internally.I ...
12
votes
3
answers
6k
views
When NOT to use database connection pooling in Java? [closed]
I can find a lot of questions about how to use connection pooling and why it's a good idea, but I'm wondering if I actually need it.
I'm creating a server application and although it is multi-...
11
votes
1
answer
4k
views
Nodejs callback mechanism - which thread handles the callback?
I'm new to nodeJS and was wondering about the single-instance model of Node.
In a simple nodeJs application, when some blocking operation is asynchronously handled with callbacks, does the main ...
9
votes
4
answers
2k
views
Animations under single threaded JavaScript
JavaScript is a single threaded language and therefore it executes one command at a time. Asynchronous programming is being implemented via Web APIs (DOM for event handling, XMLHttpRequest for AJAX ...
9
votes
2
answers
6k
views
How vert.x is single threaded?
From my understanding, each vert.x instance will be assigned an event loop. Event loop handles all the request an other task for that particular instance. Event loop is a thread, I think. When there ...
9
votes
1
answer
3k
views
Why does my activity monitor show Node.js using multiple threads?
I opened my activity monitory in OSX to to see how Node was getting along and to my surprise it's using 8 threads. How can in be!!?
8
votes
1
answer
4k
views
Can having multiple threads on a single core system still improve performance?
I just learned the basics of parallel-processing in Java.
I read this question: Multiple threads and performance on a single CPU and wondered if there is not another reason why multiple threads might ...
8
votes
2
answers
6k
views
Getting the exit code from a process submitted with qsub on Sun Grid Engine
I would like to submit jobs via qsub on Sun Grid Engine (now: Oracle Grid Engine?). I do not wish to use the -sync yes option or qrsh, because I want my controlling program to be single-threaded and ...
8
votes
2
answers
2k
views
What events specify when a tick ends in node.js?
I've read that a tick is a unit of execution where the nodejs event loop decides to run everything in its queue, but other than explicitly saying process.nextTick() what events cause the node.js event ...
7
votes
5
answers
8k
views
Deadlock in Single threaded application
Can a single threaded application have a deadlock? If so, please provide an example.
7
votes
3
answers
346
views
In javascript, why doesn't the below code exit the loop?
let a = true;
setTimeout(() => {a = false}, 1000)
while(a){console.log(a)}
7
votes
4
answers
8k
views
Is it a bad idea to use async/await in a Node/Express server?
I have a NodeJS/Express web app, where TypeOrm is used for many database functions. To avoid callback hell I usually use async/await to call and wait for database actions from my endpoint methods.
I'...
7
votes
4
answers
4k
views
Can I force the browser to render DOM changes during javascript execution
Is there a way to force the browser to render DOM changes during the execution of JavaScript? In the following example, only the '1000' will be displayed and I do understand that this is caused by ...
6
votes
3
answers
3k
views
Understanding JavaScript's single-threaded nature
I've been reading John Resig's "Secrets of a JavaScript Ninja" and it explains that JavaScript is single-threaded. However, I tried testing this and I'm not sure what to take away from here:
// ...
6
votes
1
answer
2k
views
nodejs single thread? how does it works if there are lots of concurrent requests
I am new to nodejs, currently learning it.
I know nodejs is single-threaded, however I am wondering: if I use non-blocking method,
for example, there are 20000 concurrent requests, and there is one ...
6
votes
2
answers
5k
views
If Redis is single Threaded, how can it be so fast?
I'm currently trying to understand some basic implementation things of Redis. I know that redis is single-threaded and I have already stumbled upon the following Question: Redis is single-threaded, ...
6
votes
1
answer
4k
views
Are databases single-threaded?
Let's say there is a hospital that runs a simple database. In this database is a table called "patients" with 1,000,000 records--each record being a patient whose status is either "active" or "...
5
votes
1
answer
3k
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 ...
5
votes
2
answers
3k
views
How can you have parallelism without concurrency?
I read that it is possible to have parallelism without concurrency. Is this correct?
Suppose you have two tasks, A and B, and each require two steps to complete: A1, A2, B1, B2. Also, a process is ...
5
votes
2
answers
4k
views
Asynchronous processing with a single thread
Even after reading http://krondo.com/?p=1209 or Does an asynchronous call always create/call a new thread? I am still confused about how to provide asynchronous calls on an inherently single-threaded ...
4
votes
3
answers
5k
views
Node JS multiple concurrent requests to backend API
This is my node js backend API method.
apiRouter.route('/makeComment')
.post((req, res) => {
consoleLogger.info("Inside makeComment API..");
logger.info("Inside ...
4
votes
3
answers
282
views
Is volatile useful at all in a singlethreaded application in C++?
Like the title says - is there any case in which volatile is useful in the context of singlethreaded programming? I know it's used to make sure the value of the variable is always actually checked in ...
4
votes
3
answers
3k
views
Can I force C++ library to use single thread?
I am using a proprietary C++ library on linux, compiled through gcc, which uses pthreads (I have to use the -lpthreads flag on gcc). I have a wrapper around it, and I know that the library is using ...
4
votes
4
answers
6k
views
Why is this OpenMP program slower than single-thread?
Please look at this code.
Single-threaded program: http://pastebin.com/KAx4RmSJ. Compiled with:
g++ -lrt -O2 main.cpp -o nnlv2
Multithread with openMP: http://pastebin.com/fbe4gZSn
Compiled ...
4
votes
2
answers
6k
views
How to implement a full duplex channel over TCP with a single thread?
The network lib I'm writing needs to send and receive messages through a TCP socket. Messages can be sent or received any time, i.e should work as a full duplex channel.
I was able to implement such ...
4
votes
2
answers
4k
views
Is single threaded process contains only one thread?
Can someone give more explain for single-threaded and multi-threaded processes
Is single threaded process contains only one thread? or it means that that process can contain multiple threads and can ...
4
votes
0
answers
174
views
What is a single thread of execution and runtime in Javascript?
I'm learning about the event loop from this blog but seems like the author goes into general computer program concepts I'm not too familiar with -
This includes HTTP requests, database operations ...
3
votes
6
answers
2k
views
Semaphores in a single thread
I was wondering whether it would ever make sense to use a mutex or semaphore when there is only one thread?.
Thanks for your help.
3
votes
3
answers
3k
views
Is it possible to create a single socket, single thread, TCP/IP packet reader for multiple clients?
A typical server application would create a socket for each incoming connection spawn a new thread.
However is it possible to do the demuxing yourself in a single thread? What I want is that the ...
3
votes
1
answer
4k
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 ...
3
votes
1
answer
2k
views
Single Threaded Program vs Multithreaded Program (measuing time elapsed)
I want to know if I need to measure time elapsed then Single Threaded Program is good approach or Multithreading Program is a good approach for that.
Below is my single threaded program that is ...
3
votes
1
answer
479
views
How do I check whether the other end has closed my socket stream, from a single thread?
The usocket FAQ suggests that the way I should do this is by reading from a socket-stream and checking for an end-of-file result. That works in the case where I've got one thread active per socket, ...
3
votes
1
answer
9k
views
ActiveX control cannot be instantiated because thread is in a single-threaded apartment. Happens after waking PC from sleep
I am working on a VOIP client (Window's form) that opens a browser window (ExtendedWebBrowser) when a call is made or received. Normally it works fine but if the computer is put into sleep mode and ...
3
votes
1
answer
1k
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
41
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()...
3
votes
1
answer
924
views
Performance issues of #pragma omp atomic with OMP_NUM_THREADS=1
I have observed an unexpected (for me!) behavior of an openmp code which I am writing. The code structure is the following:
#pragma omp parallel for
for(int i=0;i<N;i++){
// lots of ...
3
votes
1
answer
2k
views
Tornado non-blocking while run in single thread?
Tornado is non-blocking webserver.
However, all of the operations are run in a single thread.
How does it stay non-blocking if it is handled by single thread?
If there is a long operation, will it ...
3
votes
1
answer
2k
views
Handling multiple TcpClient connections without using threads
I've got a C# program with lots (let's say around a thousand) opened TcpClient objects. I want to enter a state which will wait for something to happen for any of those connections.
I would rather ...
3
votes
1
answer
199
views
Is volatile useful at all in a singlethreaded application in C#? [duplicate]
Is there any case in which volatile is useful in the context of single-threaded programming? I know it's used to make sure the value of the variable is always actually checked in memory so is there ...
3
votes
3
answers
1k
views
ExtJs: What will be the sequence of code execution in ajax call?
Given the fact that Javascript is a single-threaded language, what would be the sequence of execution in the following code in ExtJs?
FuncA();
Ext.Ajax.request({
url: 'ajax.php',
params: {
...
3
votes
0
answers
142
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 ...
3
votes
1
answer
1k
views
MariaDB non-blocking with EPOLL
I have single threaded server written in C that accepts TCP/UDP connections based on EPOLL and supports plugins for the multitude of protocol layers we need to support. That bit is fine.
Due to the ...
3
votes
0
answers
806
views
Comparison time- Single Threads vs Multiple Threads differing in results
I wrote this code in purpose to test multi and single threading speeds. Thanks for all the feedback! I rewrote most of it based on the great comments I received. This now functions properly (maybe has ...