Questions tagged [multithreading]

54829 questions
0

votes
0

answer
6

Views

Secondary thread causes “Application has stopped working” crashes even when invoking

I have an application which has a form with a DataGridView bound to a BindingSource, which is bound to a DataTable: bsList.DataSource = dsData bsList.DataMember = 'List' dgvList.DataSource = bsList The underlying data which populates dsData.Tables('List') can change whilst the user is working so to...
WSC
0

votes
2

answer
50

Views

Can we improve performance on lists other than java 8 parallel streams

I have to dump data from somewhere by calling rest API which returns List. First i have to get some List object from one rest api. Now used parallel stream and gone through each item with forEach. Now on for each element i have to call some other api to get the data which returns again list and save...
Pavan
-1

votes
1

answer
21

Views

JavaFX update progress bar and wait for threads to complete

I'm trying to update a progress bar in Java FX. My first problem was that the window said 'not responding' instead of actually updating. It just froze and then after the tasks were done, the progress bar became full. So I found out that I had to use multithreading and implemented it like this. overa...
Karan Bijani
1

votes
2

answer
350

Views

Can using volatile with “AtomicInteger” guarantees thread safety?

Suppose I have private volatile AtomicInteger atomInt = new AtomicInteger(3); and in methods my usage is atomInt.incrementAndGet(). Since I am using AtomicInteger, it will avoid 'thread interference'. And then I am using volatile, so it will guarantee the consistent view of the variable across all...
pjj
1

votes
1

answer
111

Views

Why does resizing a label require a delay to update as expected when coming from NotificationCenter?

I'm in the process of adding dynamic type to my app and I'm trying to update the frame of a programmatically created UILabel when the UIContentSizeCategoryDidChangeNotification notification is fired through the following code: private func configureNotificationCenter() { NotificationCenter.default.a...
elfanek
1

votes
1

answer
686

Views

what is the difference between block, suspend and sleep

For example, a process is listening on some port with block mode, so if the I/O is not ready, the process will be blocked. while (true) { msg = recv(port, BLOCKING_FLAG); // blocks here cout
Yves
2

votes
2

answer
31

Views

Full execution time multi thread java

I want to measure the full execution time (when ALL threads are done). But my code won't work here, because when the main-method ends while the other threads will still be running because they take longer time to process than the main-method. class Hello extends Thread { @Override public void run(...
Eckerd
1

votes
1

answer
394

Views

runOnUiThread without Activity [duplicate]

This question already has an answer here: Android how to runOnUiThread in other class? 6 answers executing runOnUiThread on a separate class [duplicate] 3 answers I have created an java class in android studio and I want to use runOnUiThread() in this class. Can I run runOnUiThread() thread withou...
nisarg parekh
1

votes
1

answer
303

Views

Implementation of Go-routines vs Task Parallel Library

I have just started learning Go. The strength of Go lies in goroutines for handling multiple concurrent connections. It was mentioned Goroutines can be considered as light-weight threads (but not actually threads) which can grow/shrink stack size and these are multiplexed into multiple os threads....
user3205479
1

votes
1

answer
221

Views

Thread Context and Synchronization Context

I see the use of terms Thread Context and Synchronization Context being used in documents regarding threading. Do they refer to the same thing? This is the definition for thread context by Microsoft: The thread context includes all the information the thread needs to seamlessly resume execution, i...
John L.
0

votes
2

answer
16

Views

Why can't I create a shape on jpanel?

I'm working on java gui with socket programming.I want to create jpanel on the jframe with the parameters I send from the server and create random shapes in jpanel. I used this resource to draw shapes: https://github.com/AugustBrenner/Random-Draw-Shape/blob/master/DrawPanel.java my code in jframe is...
d.k
0

votes
1

answer
15

Views

When I run this code, it just freezes while the audio plays. However, I want an animation to run simultaneously with the audio. How can I do this?

I have been trying to animate a character using Java Swing Graphics. I transition from the main screen to a JPanel that is supposed to display an animation simultaneously while audio (WAV file) runs. However, the audio runs first, and then the JPanel is shown & animated instead. How can I fix this e...
AwesomeGuy
0

votes
0

answer
6

Views

Turbogears2 with MySQL db not update tables in multi threads

I am using turbogears2 with MySQL db. With the same code, single thread case can update/write to the tables. But thread thread has no error, however, no write is successful. Outside turbogears2, multi threads can write to the tables no problems. No error or complaints with multi thread with tg2. Ju...
Simon Wu
1

votes
1

answer
67

Views

Calling async methods (Vert.x, Java) from necessarily synchronous ones

We have a set of Java applications that were originally written using normal synchronous methods but have largely been converted to asynchronous Vert.x (the regular API, not Rx) wherever it makes sense. We're having some trouble at the boundaries between sync and async code, especially when we have...
clixtec
1

votes
1

answer
41

Views

Main thread exits before the completion of CompletableFuture

CompletableFuture feature = CompletableFuture.supplyAsync (() -> composeMethod ( )). thenAccept (s -> System.out.println ('wassup java' + s)). thenRun (() -> System.out.println (' imm immortal')); nonblockingmethod ( ); This is the CompletableFuture future example im working on private static...
javaworld
1

votes
1

answer
65

Views

Simple Fast read-process

I want to decompress data from a file on a very slow device (read speed=1Mo/s). The decompression algorithm can at least perform three times this speed. What is the fastest way to parallelize those tasks in C/C++ so that reading process cannot be slow down by decompression and so use maximum bandwid...
SVA522
1

votes
1

answer
104

Views

Lparallel Package Switching in Threads

Using the Lparallel library for Common Lisp, you can start a parallel thread running by calling (submit-task channel function). This executes the given function in a new parallel thread. However, the function always seems to run in the :cl-user package, as opposed to the package in which it is defin...
davypough
1

votes
2

answer
78

Views

How to log only specific things to log file?

I'm working on web scraping where I should scrap multiple urls. I'm using ThreadPoolExecutor to do the task. I also want to implement logging in it. I want only specific debug or info or warning statements to be written to log files. But it is actually writing every request to log file. How do I ma...
Sukumar Rdjf
1

votes
4

answer
84

Views

How can I make tasks wait for the same result?

I have a simple singleton class, public class SimpleSingleton { public async Task GetRefreshedValue() { /* What goes here? */ return await GetRefreshedValueImplementation(); /* What goes here? */ } private async Task GetRefreshedValueImplementation() { /* Resource intensive and not thread safe */ }...
Jodrell
1

votes
2

answer
109

Views

How to test condition variable in C++?

I have a pretty basic method that calls wait() on a condition variable (from in C++. void WaitForEvent() { std::unique_lock lock(mutex_); while (!event_counter_) { cond_var_.wait(lock); } return; } Now I want to unit test that method's interaction. So I want to call WaitForEvent, then call PostEve...
Lexusminds
1

votes
1

answer
44

Views

Error compiling code which creates Eigen::ThreadPoolDevice object

Eigen Version 3.3.90 gcc Version 5.4.0 I'm currently trying to add multi-threading support to my Eigen Tensor project, and I've hit a problem creating the ThreadPoolDevice required to evaluate tensor operations. A minimal code example which produces the error is shown below. This is based upon the e...
PeteBlackerThe3rd
1

votes
1

answer
17

Views

Python 3 | Mutithreading starts before thread.start() is decleared

Trying to have 2 methods running at once. One is a timer method and the other writes data to a CSV. I am trying to use Treading to run them both at once, but the thread starts before it is called. Code; with open('C:\\ProgramData\\Example.txt', 'r', encoding='utf8') as file: array = for line in file...
Ac3
1

votes
1

answer
57

Views

Understanding release sequence and synchronize with in C11

I'm trying to understand memory model and reads 5.1.2.4 Multi-threaded executions and data races and is confused by the release sequence concept defined at 5.1.2.4(p10) as follows: A release sequence headed by a release operation A on an atomic object M is a maximal contiguous sub-sequence of side e...
Some Name
1

votes
2

answer
54

Views

C++ MultiThreading Mutex Locks Segmentation Fault

** This is for a college class, I am not actually trying to crack passwords ** Below is my source code, but essentially what I want to have happen is the parent process en queues passwords into an std::list attemptList. Then child threads grab from the front of the queue and, currently, just print o...
gofish
1

votes
2

answer
28

Views

Is it necessary to synchronize the methods that read a list without modifying it?

I am new to synchonization. I know that when I'm trying with multithread I can have issues adding thing to a list. For instance with the following code : import java.util.ArrayList; class MySafeList extends ArrayList{ static ArrayList mySafeList; public boolean add(Double d){ mySafeList.add(d); retu...
ThePassenger
1

votes
2

answer
57

Views

How To Know All Asynchronous HTTP Calls are Completed

I am trying to figure out how to determine if all async HTTP GET requests I've made have completed, so that I can execute another method. For context, I have something similar to the code below: public void init() throws IOException { Map mapOfObjects = new HashMap(); ObjectMapper mapper = new Objec...
Pr0pagate
0

votes
0

answer
11

Views

What is the multi threading model in Java NIO 2 - (Proactor pattern)?

I am trying to build a simple Echo Service using Java NIO 2 (which is based on Proactor Pattern). In the simplest implementation, we have 4 main components; ProactorInitiator, AcceptConnectionHandler, ReadConnectionHandler and WriteConnectionHandler. Following is my sample code. ProactorInitiator.ja...
Pasindu Tennage
0

votes
0

answer
6

Views

c# start same console application multiple times with different parameters at scheduled intervals

I have a console application that does few jobs, let's call them tasks. I want to be able to run each task individually or in parallel and one execution should not affect the other. Example if I have a console application CONSOLE A that accepts as parameter a string, an url and when is run, it get's...
user2818430
2

votes
1

answer
21

Views

Is there any disadvantage of using thread safe collection classes like Hashtable in single thread environment?

I was asked by the interviewer about disadvantages of using thread safe class like Hashtable in single threaded environment? Are there any disadvantages? if not then why are there non thread safe class introduced later?
Gurpreet Singh
0

votes
0

answer
34

Views

Async/Await: Value does not fall within the expected range

Getting the following error in my ASP.NET application 'Value does not fall within the expected range' with stack trace: System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) at System.Web.Hosting.IIS7WorkerRequest.GetUserToken() at System.Web.HttpConte...
Raghav
0

votes
0

answer
6

Views

Update Gtk+2 text view widget from another thread

I am writing a chat client in GTK. The client has the main GTK loop, plus a spawned thread that sits and blocks at the read() function waiting for input from a file descriptor connected to a socket. Once the read function gets past the blocking, it has a char buffer of text that I would like to appe...
Matthew
1

votes
1

answer
2.9k

Views

Get Thread Cpu Usage

I have a set of cpu consuming executions that each run in thread with low priority. These threads will be run in a Process (Like IIS) that have many other threads that I don't want to slow them. I want to calculate the cpu usage of all other threads and if its greater than 50% then i pause one of my...
mrd abd
1

votes
1

answer
3.1k

Views

Spring Batch thread-safe ItemReader (process indicator pattern)

I'm already implemented Remote Chunking using AMQP (RabbitMQ). Now I need to run parallel jobs from within a web container. My simple controller (testJob use remote chunking): @Controller public class JobController { @Autowired private JobLauncher jobLauncher; @Autowired private Job testJob; @Reque...
user3534805
1

votes
2

answer
1.5k

Views

The calling Thread cannot access this object because a different thread owns it. Exception

private void Thread1_Exe() { try { int sleepValT1 = Convert.ToInt32(listBoxT2.SelectedValue); int StartLoop = 0; int EndLoop = 10000; for (int i = StartLoop; i listboxE1.Items.Add('T1: Execution Count> ' + i.ToString()))); Thread.Sleep(sleepValT1); } } catch (Exception Ex) { MessageBox.Show(Ex.Mess...
Zafeer Ul Haq
1

votes
2

answer
6.2k

Views

QObject::setParent: Cannot set parent, new parent is in a different thread

Greeting I have a following class. class MyClass : public QObject { Q_OBJECT public: Q_INVOKABLE QVariant status(); public: MyClass(ClassX * classX); public slots: void slotA(); void slotB(); signals: void signalA(); void signalB(); private: void init(); void doSomething(); private: ClassX * classX;...
M.H.
1

votes
1

answer
1.4k

Views

SocketException: socket closed in accept() on ServerSocket

I had written a small code where I am trying to listen on particular port as follows (just trying out something) : public class Test { public static class MyThread extends Thread { ServerSocket ss = null; public MyThread(int port){ try { ss = new ServerSocket(port); } catch (IOException e) { System....
Furquan Ahmed
1

votes
1

answer
472

Views

Not able to start Thread from Laravel Command

I am new to pthreads in php. I have learnt that it is not possible to start it from apache through a webserver so I have resorted into using laravel commands to run it from the command line but I get this error when I call the start() method of the thread PHP Fatal error: Uncaught Exception: Seri...
Algorithm
1

votes
2

answer
546

Views

Multithreading ping inside BASH script

I've had a look around here and there only seems to be one question raised in regards to the multithreading of ping inside a BASH environment. Code data=$( /dev/null & echo $line is reachable || echo $line is down done The issue is that it cycles through the IP address range inside the file and repo...
Danny Watson
1

votes
2

answer
860

Views

what is best practice to consume messages from multiple kafka topics?

I need to consumer messages from different kafka topics, Should i create different consumer instance per topic and then start a new processing thread as per the number of partition. or I should subscribe all topics from a single consumer instance and the should start different processing threads...
Megha
1

votes
1

answer
88

Views

Swift Threading: When to use DispatchQueue.main.async?

I believe I understand what the dispatch queue is doing when I call it, but I'm not sure when exactly I should use it and what it's advantages are when I do use it. If my understanding is correct, DispatchQueue.main.async { // code } will schedule the code contained within the closure to run on the...
YungGun

View additional questions