multithreading

User prompts with multithreading

不羁的心 提交于 2021-02-11 12:17:05
问题 I have a couple threads running at once, doing things in the "background", but then the program reaches a point where it needs user input for all the threads to continue. Below is what I have written, and it works, but it seems inefficient and I'm not sure how else to do it as this is my first experience with multi-threading. global userPromptFlag = 1 # first thread to reach this condition prompts the user for info if (userPromptFlag == 1): userPromptFlag = 0 self.userPrompts() else: # other

JAVAFX media : Serious optimization problem

浪子不回头ぞ 提交于 2021-02-11 12:15:51
问题 the program is a system that shows media: images, videos and keeps alternating between them. the problem is the use of increasing memory: after the programming running for 30 minutes, it consumes 1.2gb of ram I do not have much idea of what I can do, I believe that the reason for the increasing memory consumption would be recursion (the function calls itself) or the fact that every time it gives a picture it creates a thread, and when it video it uses the technically 'correct' which is a

Firing Recurring Tasks At The Same Time

怎甘沉沦 提交于 2021-02-11 11:58:53
问题 I am trying to get 2 tasks to fire at the same time at a specific point in time, then do it all over again. For example, below is a task that waits 1 minute and a second task that waits 5 minutes. The 1 minute task should fire 5 times in 5 minutes and the 5 minute task 1 time, the 1 minute task should fire 10 times in 10 minutes and the 5 minute task 2 times, on and on and on. However, I need the 1 minute task to fire at the same time as the 5 minute. I was able to do this with System.Timers

C# Producer-Consumer using Semaphores

不羁岁月 提交于 2021-02-11 10:24:27
问题 Inspired by The Little Book of Semaphores, I decided to implement the Producer-Consumer problem using Semaphores. I specifically want to be able to stop all Worker threads at will. I've tested my methodolodgy extensively and can't find anything faulty. Following code is a prototype for testing and can be ran as a Console application: using System; using System.Collections.Concurrent; using System.Threading; using NUnit.Framework; public class ProducerConsumer { private static readonly int

Is it possible for an app to have several PID at the same time?

两盒软妹~` 提交于 2021-02-11 10:17:21
问题 I have done some experiments and to my knowledge, an app can create several instances of ART (AndroidRunTime) that can execute code concurrently. Each of these instances are called by the same PID than the app. Each of these ART instances can create several threads and these threads have the app PID. But is it possible for an app to have several PID simultaneously? If it is the case could you provide an example? 来源: https://stackoverflow.com/questions/41898846/is-it-possible-for-an-app-to

Is it possible for an app to have several PID at the same time?

情到浓时终转凉″ 提交于 2021-02-11 10:17:05
问题 I have done some experiments and to my knowledge, an app can create several instances of ART (AndroidRunTime) that can execute code concurrently. Each of these instances are called by the same PID than the app. Each of these ART instances can create several threads and these threads have the app PID. But is it possible for an app to have several PID simultaneously? If it is the case could you provide an example? 来源: https://stackoverflow.com/questions/41898846/is-it-possible-for-an-app-to

Python Multithreaded Queue remaining “empty”

◇◆丶佛笑我妖孽 提交于 2021-02-11 10:00:12
问题 I have a python application that is being built to run some tests that involves using a Null Modem USB-to-USB (Currently using an emulator on PC) to send serial data from one USB port to another. I have written a serial listener as follows: import serial import threading from queue import Queue class SerialPort(object): def ___init__(self, timeout=None): self.ser = serial.Serial(baud=_, stopbits=_, ... timeout=timeout) self.out_q = Queue() self.in_q = Queue() self.THREAD = None def setup(self

Python Multithreaded Queue remaining “empty”

冷暖自知 提交于 2021-02-11 09:58:32
问题 I have a python application that is being built to run some tests that involves using a Null Modem USB-to-USB (Currently using an emulator on PC) to send serial data from one USB port to another. I have written a serial listener as follows: import serial import threading from queue import Queue class SerialPort(object): def ___init__(self, timeout=None): self.ser = serial.Serial(baud=_, stopbits=_, ... timeout=timeout) self.out_q = Queue() self.in_q = Queue() self.THREAD = None def setup(self

Regularly report progress of a BackgroundWorker

こ雲淡風輕ζ 提交于 2021-02-11 09:47:38
问题 I'm writing a music player. This is the (early) code that adds a directory to the playlist: private void SelectFolderButton_Click(object sender, EventArgs e) { int count = 0; AddFolderDialog.ShowDialog(); if(AddFolderDialog.SelectedPath != string.Empty) { BackgroundWorker bgw = new BackgroundWorker(); bgw.DoWork += (a,b) => playlist.AddFolder(AddFolderDialog.SelectedPath, RecursiveCheckBox.Checked, out count); bgw.RunWorkerAsync(); bgw.RunWorkerCompleted += (a, b) => mainStatusLabel.Text =

Can I call a thread recurrently from within a thread?

与世无争的帅哥 提交于 2021-02-11 08:11:00
问题 I'm trying to transfer samples from thread A ("Acquisition") to thread B ("P300") using queue but I can't read any data in thread B, although samples are being allocated in thread A. Judging by my output, I think my thread B is rushing and testing things before my thread A starts to put data in. See an approximation of my code structure bellow: import threading import queue from queue import Empty import numpy as np import warnings warnings.filterwarnings("error") class AcqThread(threading