multithreading

How to make Qt work when main thread is busy?

Main (function main is there) thread of my program is reserved for non-GUI tasks. It calls a number of lengthy calculation functions. All implemented GUI's have been doing their work in a separate threads. I'm now going to implement one more GUI using Qt. Qt documentation says all GUI related tasks should be done in main thread. In my ...

C# Update Form from threading & class

I working on project and have problem with threading and update of UI. I read many post around web and this site, but didnt find answer to my problem. I making program that a waiting for some UDP data on port XXXX. Looping in separated thread. When data come he extract information and put it in buffer, and go back wait another data. Ano...

Problem with CURL (Multi)

I'm having a problem with curl_multi_*, I want to create a class / function that receives, lets say 1000 URLs, and processes all those URLs 5 at a time, so when a URL finishes downloading it will allocate the now available slot to a new URL that hasn't been processed yet. I've seen some implementations of curl_multi, but none of them al...

Handling gui with different threads

I'm new in qt and c++, and I have a problem with threads. For example, if I have a gui with two QPushButton and one QTextEdit, is it possible to set values to the QTextEdit from a thread (different from the gui main thread) without freezing the gui? // These are the values that I want to set from the thread for(i=0;i<100;i++){ ...

Java Thread using static or non-static nested class

I've encountered a very strange problem. My program looks like this: class Outter{ class Inner extends Thread { public void run(){ // do something } } public void func() { new Inner().start(); // Thread.sleep() for a while to see if the above thread has fin...

How can I execute binaries from Ruby threads and remain threaded?

I tried to make a script that would execute several external binaries to perform some tasks. Each binary was executed from a different thread, but the thing is, it didn't work ( because of the implementation of Ruby's threads in 1.8.6 ). Is there a different way I could do this, or do I have to go with Ruby 1.9 ? ...

Time synchronization in java

Hi there! Inside a for-loop I'm controlling the simulation-step-based traffic simulator SUMO by retrieving and processing information of vehicles. To make sure that my program simulates in "real-time" (1 simulation-step = 1 second) I want to sleep my program after the processing phase until the next time step begins. To get better resul...

Are rails controllers multithreaded? Thread.exclusive in controllers

Are Rails controllers multithreaded? If so, can I protect a certain piece of code (which fires only once every ten minutes) from being run from multiple threads by simply doing require 'thread' Thread.exclusive do # stuff here end on do I need to somehow synchronize on a monitor? ...

Interlocked used to increment/mimick a boolean, is this safe?

Hi, I'm just wondering whether this code that a fellow developer (who has since left) is OK, I think he wanted to avoid putting a lock. Is there a performance difference between this and just using a straight forward lock? private long m_LayoutSuspended = 0; public void SuspendLayout() { Interlocked.Exchange(ref m_L...

C#: Preloading forms on a separate thread.

I have some forms that takes a bit of time to open because they currently get some stuff from a database in their Load event handler. Is it possible to somehow load the forms in a separate thread and show them to the user when that is done? If loading them so that the Load event handler is fired is not possible, maybe having a IPreload...

C#: How to prevent Invoke from failing

I have a UserControl with something that does some background work. When thing has a completed event, which the user control is subscribed to. Since the event is raised in a separate thread and the event handler does some updating of the user control I start the event handler with this: private void ProcessProcessCompleted(object sender...

How can I run gtk.main() asynchronsly in pygtk?

The basic code that I have so far is below. How do I thread gtk.main() so that the code after Display is initialized runs asynchronously? import pygtk pygtk.require("2.0") import gtk class Display(): def __init__(self): self.fail = "This will fail to display" window = gtk.Window(gtk.WINDOW_TOPLEVEL) window....

Should I make all my java code threadsafe ?

I was reading some of the concurrency patterns in Brian Goetze's Java Concurrency in Practice and got confused over when is the right time to make the code thread safe. I normally write code that's meant to run in a single thread so I do not worry too much about thread safety and synchronization etc. However, there always exists a possi...

How to get the cpu usage per thread on windows (win32)

Looking for Win32 API functions, C++ or Delphi sample code that tells me the CPU usage (percent and/or total CPU time) of a thread (not the total for a process). I have the thread ID. I know that Sysinternals Process Explorer can display this information, but I need this information inside my program. ...

threaded NSProgressIndicator problem

I'm trying to figure out how to update an indeterminate NSProgressIndicator in the UI using a secondary thread while the main thread does some heavy lifting, just like dozens of apps do.This snippet is based on Apple's "Trivial Threads" example using Distributed Objects (DO's): // In the main (client) thread... - (void)doSomethingSlow:(...

Best Practices: hasXXX() methods for possible null returning getXXX() methods.

Hello! This question might appear very simple, but i haven't found an answer yet, so i'm asking the stack overflow community. As the title suggests i have a Class with several getXXX() methods where some of them may return null. This is documented and the user of this class should be aware of this fact. To simplify the usage of this cl...

Determining which locks are most contended?

Our application has ~10 threads doing separate tasks (no thread pools). We are not experiencing deadlock, but are always trying to lower latency to respond to a request so we are interested in determining which locks are the most contended. jconsole shows how often threads are blocked, and it isn't very often, but we still want to know...

ConcurrentHashMap Conditional Replace

I'd like to be able to conditionally replace a value in a ConcurrentHashMap. That is, given: public class PriceTick { final String instrumentId; ... final long timestamp; ... And a class (let's call it TickHolder) which owns a ConcurrentHashMap (let's just call it map). I wish to be able to implement a conditional put m...

Create a timer on a different thread - with no callback function (C, Windows)

Is there a way to create a timer (say, to 10 seconds) on a different thread? I mean, I know how to use CreateThread() and I know how to create/use timers. The problem I have is that the new thread cannot receive a callback function. For those that will inevitably ask "why do you want to do this?" the answer is because i have to do it th...

Socket.BeginReceive Performance on Mono

Hi to all, this is my first post here, i hope to find someone that can help to clarify my doubts! I'm developing a server in C#. This server will act as a data server for a backup service: a client will send data, a lot of data, continuously, specifically will send data chunk of files, up to five, in the same tcp channel. I'll send dat...