multithreading

Delphi - adjusting thread sleep time

Hi. There are several threads in my application that work in the background. They connect to database and execute some time consuming select queries. In most of cases these queries return only several records. From time to time, however, they may return tens of thousands records. All these are then processed in a loop. Because such sit...

Implementing a global lock in Java

Hi, I have a relatively simple (perhaps stupid) question regarding synchronisation in Java. I have synchronisation blocks that acquire locks on various objects throughout my code. In some scenarios, I want to acquire a global lock that subsumes every other synchronisation statement in my code. Is there a fancy way to do this in Java w...

C# - How do I Pass a delegate into another method?

I'm writing a class for managing my threading. How do I pass my method that needs threading into my helper class? All that I'll be doing is creating a new thread and passing the method I've passed through into a new ThreadStart(). Thanks in advance. ...

Instance methods called in a separate thread than the instantiation thread

I'm trying to wrap my head around what is happening in this recipe, because I'm planning on implementing a wx/twisted app similar to this (ie. wx and twisted running in separate threads). I understand that both twisted and wx event-loops need to be accessed in a thread-safe manner (ie. reactor.callFromThread, wx.PostEvent, etc). What I...

How to manipulate this interface?

I have seen lots of kinds of interface to multithreading and locks. These make me feel frustrating, Some of them include 2 different classes like the sample below, while others have only one class and the acquire() can implement the wait function. My questions are: Why we design locks like this in object oriented programming? How t...

waking up one thread from another

I am using .NET (C#). if I have 2 threads running T1 and T2 and T1 is like this: while (true) { dosomething(); //this is a very fast operation sleep(5 seconds); } at the same time T2 is doing something completely different however from time to time it needs to give T1 a kick such that it wakes up from the sleep even though the s...

Java Threads

How do I implement a ThreadPoolExecutor? What needs to be done to use it? ...

WaitForSingleObject( )

I have got myself stuck into a really amazing issue here.The code is like as below. class A { public: A(){ m_event = CreateEvent(NULL, false, false, NULL); // create an event with initial value as non-signalled m_thread = _beginthread(StaticThreadEntry, 0, this); // create a thread } stat...

How can Unix pipes be used between main process and thread?

I am trying to channel data via pipes whenever a signal arrives from a thread to the main process. Is this possible? How can this be done? The problem: A child thread reads data and puts it into a queue. Main application does its own stuff, however, when data is available on the queue, it should be notified by the thread, and st...

Linux Wireless Network Testbed

Hi all, I am writing a linux testbed for wireless sensor networks. The core objective is to test data transfer between any two nodes. The network runs using tree topology. One node in the network is the "Driver". This node is connected using serial port to a linux PC. What I am trying to write is the software on this linux PC that will ...

crawling scraping and threading? with php

I have a personal web site that crawls and collects MP3s from my favorite music blogs for later listening... The way it works is a CRON job runs a .php scrip once every minute that crawls the next blog in the DB. The results are put into the DB and then a second .php script crawls the collected links. The scripts only crawl two levels...

Read/Write Locks

As part of a project at work, I implemented a Read/Write lock class in C++. Before pushing my code to production, what sort of tests should I run on my class to be sure it will function correctly. I've obviously performed some sanity tests on my class (making sure only one writer can access at a time, making sure releases and claims ...

Java seems to support volatile fields of type long, while C# does not - What are the reasons behind this?

Can anyone explain to me what the benefits and and drawbacks of the two different approaches are? ...

Why lock may become a bottleneck of multithreaded program?

Why lock may become a bottleneck of multithreaded program? If I want my queue frequently pop() and push() by multithread, which lock should I use? ...

Sending string data between threads (Win32)

Hi all, This is a fairly straightforward question, I'm basically looking for a 'best practice' approach to what I'm trying to do. I have a Win32 GUI application which starts up a worker thread to do a bunch of blocking calls. I want this thread to send string messages back to the GUI so they can be displayed to the user. Currently I'm...

How to solve this specific threading problem

Using the code from the following article, I implemented an own ThreadPool: http://www.developer.com/net/article.php/3783756 This is what I want to achieve: Triggered through a Timer, a service should query a database every 5 seconds for new jobs to execute. A Job is basically only the information about a commandline program that needs ...

How come the WaitForDeath() can kill the thread in the sample?

class Thread { public: Thread ( DWORD (WINAPI * pFun) (void* arg), void* pArg) { _handle = CreateThread ( 0, // Security attributes 0, // Stack size pFun, pArg, CREATE_SUSPENDED, &_tid); } ~Thread () { CloseHandle (_handle); } void Resume () { ResumeThread (_hand...

Does Thread.Sleep affect ThreadState?

If I create and start a thread, how does calling Thread.Sleep(x) within that thread affect the ThreadState (if at all)? Thanks! ...

Threads in Java and Python

Hi all, i have few questions about threads in Python and Java... Is it possible to give priorities to Python threads, as it is in Java? How can I kill, stop, suspend and interrupt thread in Python? Thread groups - what are they really for? Does Python support them too? Synchronization - in Java we use simply keyword synchorinized for a...

WCF comet and threads

Hi, I'm trying to use WCF to implement a comet style server push to an ajax web application. In my WCF service, I've implemented a WaitForEvents method that calls Monitor.Wait to suspend the thread until new data arrives. At that point, the Monitor is pulsed, and the method returns the new data which closes the comet style request. The...