Questions tagged [multithreading]

54753 questions
1

votes
1

answer
98

Views

How to loop a function for a period of time

Trying to loop a function for a specific period of time, bear in mind the function takes about 20 seconds to finish executing. There's obviously the option of using something along the lines of: long startTime = System.currentTimeMillis(); long length = 30000; while(System.currentTimeMillis() - star...
a.khaled
1

votes
3

answer
364

Views

How to wait for a AdMob Rewarded Video to Load properly

I am trying to use the AdMob Rewarded Ad in my Android application. In order to include it in the refered app, I need to wait for the rewarded video to load after the user click the buttom. I am trying it throughout the code bellow, but I get the error: java.lang.IllegalStateException: showAd mus...
Siqueira
1

votes
0

answer
61

Views

C++ calls cv2 in python with multithreading

C++ calls Python.(Python3.6+VS2012+opencv_python‑3.4.0‑cp36‑cp36m‑win_amd64) I initialize Python in the main thread, and execute python statements in sub-thread. I can normally call skimage, sklearn and numpy in any thread apart from cv2. When i use cv2 in the sub-thread, the program will be...
user9147627
1

votes
0

answer
277

Views

POSIX spawn.h and /sys/wait.h on Visual Studio Windows platform

This is similar to a question in a very old thread (7 year old thread) available here: can't get my code to run from a programming book(c++) (So, instead of posing this question there, I wanted to post as a new thread.) Essentially, the following code from book Professional Multicore Programming doe...
Tryer
1

votes
0

answer
71

Views

Parallel SpMV using MKL slows down with increasing thread number

I'm calling intel MKL for csr format SpMV. To accelerate, I'm using multiple threads by mkl_set_num_threads. However, when the threads increases, the performance slows down. Any idea what's going on? Though the documents say the thread number specified by mkl_set_num_threads only limits the maximu...
WalkerShaw
1

votes
0

answer
81

Views

c++ async : how to shuffle a vector in multithread context?

Running a multithreaded program, I noticed that the program was running faster using 1 thread compared to 4 threads, despite the CPU having 4 cores. After investigating, I found out that the issue appears only when shuffling something. Below the minimal program I created to reproduce the problem: #i...
Vince
1

votes
1

answer
215

Views

SetThreadContext modifies only the last 32 bits of RIP in x64

For an unknown reason, SetThreadContext does not work as intended in an x64 process. I intent to use it on a suspended thread to modify the instruction pointer and make the thread execute some shellcode. Unfortunately, SetThreadContext seem to only modify the last 32 bits of the x64 instruction poin...
Pierre Ciholas
1

votes
0

answer
157

Views

Is it possible to use IO.pipe for inter-thread communication in Ruby?

In the Ruby IO.pipe example from the documentation, a single message is passed through the processes. I wanted to do something similar, with two differences: use threads instead of processes use a pipe for ongoing messaging, not for a once-off message This is the obvious, but non-working code: rd, w...
Marcus
-1

votes
3

answer
49

Views

Fast reading large table

I have csv file structured as below: 1,0,2.2,0,0,0,0,1.2,0 0,1,2,4,0,1,0.2,0.1,0 0,0,2,3,0,0,0,1.2,2.1 0,0,0,1,2,1,0,0.2,0.1 0,0,1,0,2.1,0.1,0,1.2 0,0,2,3,0,1.1,0.1,1.2 0,0.2,0,1.2,2,0,3.2,0 0,0,1.2,0,2.2,0,0,1.1 but with 10k columns and 10k rows. I want to read it in such a way that in the result i...
Adam Stawarek
0

votes
0

answer
2

Views

Maximum number of CUDA blocks?

I want to implement an algorithm in CUDA that takes an input of size N and uses N^2 threads to execute it (this is the way the particular algorithm words). I've been asked to make a program that can handle up to N = 2^10. I think for my system a given thread block can have up to 512 threads, but for...
gkeenley
0

votes
0

answer
4

Views

How to pre load batch audience native ads in background thread

Tried to load facebook audience network in background thread but it gives me an exception. I have a content feed where I show Ads. I pre fetch the ads using the audience network sdk, however the App becomes slow over time as more ads get fetched when user the scrolls. I tried to fix this problem by...
user11040612
1

votes
1

answer
94

Views

Dispatch Thread Groups Error

I am running computer vision algorithms on a video feed I'm getting in real time. I'm running these operations/algorithms using DispatchQueue asynchronously. However, I am getting the following error, which I cannot interpret: [MTLDebugComputeCommandEncoder dispatchThreadgroups:threadsPerThreadgrou...
AJ Z.
1

votes
0

answer
237

Views

How does Network I/O happens in node.js?

I have been searching about the node.js internal thread pool for I/O and found out that Network I/O does not use threads for requests. 1) Then what puts the cap on limit of network request processed asynchronously in my node.js server? I am trying to use cluster module on my octa core processor and...
Abhishek Yadav
1

votes
0

answer
56

Views

Scaling node.js servers

I have some basic doubts regarding node.js scaling Problem Explanation I am solving a problem where I have multiple devices that send data at high frequency, I need to process the data(Based on the data, some network I/O has to be done) and save it to the database. I first designed this architecture...
Abhishek Yadav
1

votes
0

answer
56

Views

How to disconnect from one end point and then connect to another? - C#

I have two servers and a client. One server is on the same computer where the client is. I need to disconnect from the local server and connect to the remote one. AutoResetEvent disconnectDone = new AutoResetEvent(false); IPEndPoint localEndPoint = new IPEndPoint(Dns.Resolve(Dns.GetHostName()).Addre...
J. Doe
1

votes
0

answer
55

Views

What if there was no future.isDone check in the invokeAll method

If we check the invokeAll method in AbstractExecutorService class, then we can see that following things are happening: Submission of the tasks in a for loop Running of another for loop. And in case the future is not completed , then do a get on it (to make sure that all the futures are finished bef...
Gaurav
1

votes
2

answer
53

Views

Running a thread by toggling a flag externally (from GUI)

I am making a simple JavaFX college course project and I need a good way of dealing with threads, mainly running them while a certain flag is activated. This is a simple sketch I came up with: public class ListenerService extends Thread { private static ArrayList listeners = new ArrayList(); private...
0lt
1

votes
1

answer
308

Views

Is akka really a solution for a deadlock?

As Described here While locks seem to be the natural remedy to uphold encapsulation with multiple threads, in practice, they are inefficient and easily lead to deadlocks in any application of real-world scale. My question simply, is akka really a solution for a deadlock. I know as long as akka actor...
user2810472
1

votes
0

answer
198

Views

How to send broadcast data to all clients in a muti-threaded socket server?

I am currently in the process of creating a mutli-threaded chat room in python, however I am having trouble broadcasting data to all of the clients. I am hoping to create a system where one clients sends data to the server, and the server broadcasts the data to the other clients. What I am hoping to...
1

votes
1

answer
72

Views

How to close a socket which is locked in an infinite loop?

I have created a server-client project where the server keeps listening and prints the information. However, when i shutdown the client, the server remains open. The problem is that I need to insert this into another application, and, if the server does not close at first, the application will not o...
André Spironello
1

votes
0

answer
49

Views

Calling method on autowired controller hangs when executed on a new thread

I have a very simplified code sample below, but basically I have a scheduler that calls a controller on a new thread. In that new thread MOST autowired beans work fine, but one of them, MyController, just hangs if i try and invoke it for any reason. The only thing i can find different about MyContr...
GavinF
1

votes
0

answer
41

Views

NodeJS: Delete futures running a thread to make new ones

I am working with legacy code written in Nodejs. There is a scheduler class which takes functions as input and starts a thread wrapped in a future. const t = threads.spawn(fn); future_ary.push(futures.newFuture(t)); Where the futures is just a wrapper class that does some book keeping and creates th...
danny
1

votes
0

answer
186

Views

FreeTTS - Multiple voices at once

I'm currently writing a Java application (chat app) which requires text-to-speech. After looking online for a bit I found out that FreeTTS is a good option, I managed to get it work, and it currently prevents the main UI thread from being blocked as I'm running it in a thread. The only issue is that...
Paradoxis
1

votes
0

answer
43

Views

performSelector queue & runloop schedule

I have read apple's code example ListAdder about how to use NSOperation. Technical Note TN2109 also explains the details. If there is already an Operation calculating, and the user delete a data by remove a cell from the tableview, then the tableview delegate method will be called and tiggers new Op...
blueGhost
1

votes
1

answer
55

Views

How to add layer, created by another thread, to Axmapcontrol

I have a geodatabase that contains raster datasets. I can read these datasets and convert them to layer. I want to add these layers, created another thread, to axmapcontrol but i got the error 'vshost32 has stopped working'. I tried Invoke method, Action method and Backgroundworker but none of them...
Abdurrahman KABALCI
1

votes
1

answer
136

Views

Swift 3 tableview.reloadData on main thread, not displaying cells properly

In a simple TableViewController i am calling ClouKit deleteRecord in a UIAlertController. // 2. When the user clicks OK. alert.addAction(UIAlertAction(title: 'OK', style: .default, handler: { [weak alert] (_) in LSCloudKit.shared.deleteRecord(record: login.toCKRecord(), completion: { (success) in le...
Pascal Duff
1

votes
0

answer
107

Views

HashMap with std::future as the key

Since we cannot get the arguments from std::future, I am trying to maintain a map between std::future and std::string. The following statement: std::unordered_map map fails with the following error: error: no match for call to '(const std::hash) (const std::future&)'...
UnderWood
1

votes
0

answer
31

Views

javafx: How to multithread windows and pass information between them?

I am currently working on a JavaFX app. This app contains a main window and several different input windows, which are opened by button clicks. The following code simplyfies my app to the necessary part of code. As in the real app, by clicking the button in the main window the inputwindow opens. The...
zimi90
1

votes
0

answer
105

Views

Python thread retry every X seconds up to Y minutes

I'm trying to implement the client-server architecture in Python, where I have: Server application List of clients, who can subscribe to updates via API (sending POST requests to /subscribe endpoint). It works fine. On the server side, I have a list of subscriber's URLs. The main idea is to send req...
smart
1

votes
0

answer
753

Views

Flask Countdown Timer without Sleep [duplicate]

This question already has an answer here: How many concurrent requests does a single Flask process receive? 4 answers Handle Flask requests concurrently with threaded=True 2 answers Display data streamed from a Flask view as it updates 1 answer I'm writing a web app with Flask and when I try to c...
user3246092
1

votes
1

answer
79

Views

Volatile variables in Server EndPoint for WebSocket Java API?

Looking at other examples across the web, when a server endpoint is created by means of Java API for WebSocket, the shared variables among all EndPoint instances are defined as static, but not volatile. I would like to know the reason. As I understand, the clients opening websockets will create a ne...
MickeyMouse
1

votes
0

answer
49

Views

Qt and manual input events

I am trying to process manually created input event like this: class WebView : public QWebView { Q_OBJECT public: ... Q_INVOKABLE bool ProcessEvent(QEvent *ev) { bool res = this->event(ev); delete ev; return res; } ... }; And send it from another thread like this: QEvent *ev = new QMouseEvent{ QEven...
user1188351
1

votes
0

answer
61

Views

Python threads and scipy.interpolate.interp2d

I have this class that creates random 2d maps. The following code does nothing except creating the map since I've stripped it down to isolate the bug: import numpy as np from scipy.interpolate import interp2d class CRelevanceMap: def __init__(self): self.relmap = self._create_map(4, 6) def _create_m...
Claudio
1

votes
0

answer
338

Views

Python threading error, can't run script

I am not sure why, but I keep getting an error when I try to run one of my python programs. It is a simple script, as I was trying to understand how threading works. This is the code I am using for the example: import threading import time def myfunction(): print('Start a thread') time.sleep(3) prin...
otterdog
1

votes
0

answer
218

Views

What's the difference between Sequential and Synchronous Execution?

If I understand it correctly: Asynchronous Execution - One task doesn't have to wait for another to finish Concurrent Execution - Two tasks are being worked during a common time period (usually through context switching) But the opposites of both of those seem the same. Synchronous Execution - One...
master_of_privates
1

votes
0

answer
193

Views

Returning thread-local data from a shared library C-api

Question 1: Is it safe and portable to return a pointer to a thread_local data from a shared library providing a traditional C-API? The lib itself is naturally implemented with C++11. Safetyness in respect to memory leaks and race conditions, portablitity covering the main desktop OSs: Windows, Lin...
Strueddalfie
1

votes
1

answer
87

Views

Java MultiThread: unexpected execution time

I'm currently checking the behaviour of multithreading in Java and I'm getting an unexpected result. Here's what I'm doing: Generating 50 random adjacency matrices with a size of 600x600 and save them to a .txt file Reading these matrices and running Floyd Warshall algorithm with N threads (from 1 t...
John F
1

votes
0

answer
65

Views

Optimization: alternatives to passing large array to map in ipyparallel?

I originally wrote a nested for loop over a test 3D array in python. As I wanted to apply it to larger array which would take a lot more time, I decided to parallelise using ipyparallel by writing it as a function and using bview.map. This way I could take advantage of multiple cores/nodes on a supe...
mallowcodes
1

votes
0

answer
37

Views

Running fast function and slow function with multi-threading in matlab

I'm new with multi-threading in Matlab so I guess that what I need to do will be simple for anyone with a little experience in it. I have two functions f1 and f2 such that: f1 - runs about 10 seconds and returns accurate results. f2 - return estimated results immediately. Both functions get the same...
David
1

votes
3

answer
66

Views

Make the main thread wait till new single thread executes completely in java [duplicate]

This question already has an answer here: How to wait for a number of threads to complete? 13 answers Scheduler gets the configuration from the server through new single thread. But application continues to execute even when the scheduler is executing the config() to get the configuration from the...
MANOJ

View additional questions