multithreading

How can I dispatch an PropertyChanged event from a subscription to an Interval based IObservable

I'm getting an 'UnauthorizedAccesExpection - Invalid cross-thread access' exception when I try to raise a PropertyChanged event from within a subscription to an IObservable collection created through Observable.Interval(). With my limited threading knowledge I'm assuming that the interval is happening on some other thread while the even...

Swing: what to do when a JTree update takes too long and freezes other GUI elements?

Hello, everyone! I know that GUI code in Java Swing must be put inside SwingUtilities.invokeAndWait or SwingUtilities.invokeLater. This way threading works fine. Sadly, in my situation, the GUI update it that thing which takes much longer than background thread(s). More specific: I update a JTree with about just 400 entries, nesting de...

How to create a console application that does not terminate?

Hello, In C++,a console application can have a message handler in its Winmain procedure.Like this: int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { HWND hwnd; MSG msg; #ifdef _DEBUG CreateConsole("Title"); #endif hwnd = CreateDialog(hInstance, MAKEINTRESOURCE(ID...

PHP thread pool?

I have scheduled a CRON job to run every 4 hours which needs to gather user accounts information. Now I want to speed things up and to split the work between several processes and to use one process to update the MySQL DB with the retrieved data from other processes. In JAVA I know that there is a thread pool which I can dedicate some t...

C# Application process hangs after some time

Hi, I implemented a simple C# application which inserts about 350000 records into the database. This used to work well and the process took approximately 20 minutes. I created a progress bar which lets you know approximately the progress of the records insertion. When the progress bar reaches about 75% it stops progressing. I have to m...

C# Threading and Sql Connections

I have a method that attempts to update a sql server database in an ASP.NET application. If the update fails, it catches the exception and then queues the update in MSMQ, and then spins up a new thread that will later de-queue the pending update and try again. When the thread starts, it fails to open a database connection because it is a...

time required to finish the multithreaded program??

A java process starts 5 threads , each thread takes 5 minutes. what will be the minimum and maximum time taken by process? will be of great help if one can explain in java threads and OS threads. Edit : I want to know how java schedule threads at OS level. ...

How to achieve a specific fraction(say 80%) of the cpus and balanced over them

Hi, I was wondering if it would be possible to run app not at 100% of the cpu but at a specific amount of the cpus. I see different usage of this , we can better balance concurrent application ( we may want to have balance app 50% to have fair apps/agent/... ) i was also wondering if the power consumption would not be better if t...

How effective is Thread.sleep(long)?

Let's say I want to "pause" a thread so that other threads can run more efficiently. What is the minimum sleeping period before blocking becomes pointless (or almost pointless)? ...

linux thread synchronization

I am new to linux and linux threads. I have spent some time googling to try to understand the differences between all the functions available for thread synchronization. I still have some questions. I have found all of these different types of synchronizations, each with a number of functions for locking, unlocking, testing the lock, ...

What are the different ways of implementing multithreading in .net

I have been fighting with multi threading for few days. I dont understand what are different ways of multithreading. I have read little bit about backgroundWorker, little bit about creating an object of thread. Yesterday I saw in delegate example to implement multithreading by calling BeginInvoke. I dont understand are these differe...

Delegating code to run from main thread for handling gui from main thread

I have some code which is been running by a backgroundworker I'd like some specific code which shows some GUI to run in the main thread context (2 reasons 1. it should be blocking 2.I know it's problematic to handle gui controls from a background worker) I raise an event pass the class and listen to the event in the mainForm from there I...

Good source to learn multithreading with .net?

Can somebody point me to a good site/book/article about multithreading with .net? I didn't find much info about this... thanks ...

Socket.Recieve Failing When Multithreaded

The following piece of code runs fine when parallelized to 4-5 threads, but starts to fail as the number of threads increase somewhere beyond 10 concurrent threads int totalRecieved = 0; int recieved; StringBuilder contentSB = new StringBuilder(4000); while ((recieved = socket.Receive(buffer, SocketFlags.None)) > 0) { contentSB.Appen...

prevent linux thread from being interrupted by scheduler

How do you tell the thread scheduler in linux to not interrupt your thread for any reason? I am programming in user mode. Does simply locking a mutex acomplish this? I want to prevent other threads in my process from being scheduled when a certain function is executing. They would block and I would be wasting cpu cycles with context ...

Is this a correct Interlocked synchronization design?

I have a system that takes Samples. I have multiple client threads in the application that are interested in these Samples, but the actual process of taking a Sample can only occur in one context. It's fast enough that it's okay for it to block the calling process until Sampling is done, but slow enough that I don't want multiple threa...

How can I use multithreading in a Windows Forms application to update a progress bar?

There are two objects. The Windows Form with a button and a progress bar, and another object that handles an algorithm. In the algorithm object there is an event, and a property. The event is ProgressChanged, and the property is Progress (which is an int). In the calling window, the button starts off a set of steps in the algorithm o...

Segmentation fault in Thread pool

i am creating a bluetooth based server program in Bluez which basically handles connections from multiple devices. I have constructed two threads; one to scan the remote devices and another to connect with the devices that are broadcasting the service. Again, a separate thread is extracted from a thread pool for each of the newly connect...

Android ProgressDialog Progress Bar doing things in the right order

I just about got this, but I have a small problem in the order of things going off. Specifically, in my thread() I am setting up an array that is used by a Spinner. Problem is the Spinner is all set and done basically before my thread() is finished, so it sets itself up with a null array. How do I associate the spinners ArrayAdapter wi...

Java - Call to start method on thread : how does it route to Runnable interface's run () ?

Ok , I know the two standard ways to create a new thread and run it in Java : 1 Implement Runnable in a class , define run method ,and pass an instance of the class to a new Thread. When the start method on the thread instance is called , the run method of the class instance will be invoked. 2 Let the class derive from Thread, so it ca...