multithreading

How can you ensure in java that a block of code can not be interrupted by any other thread.

exampl: new Thread(new Runnable() { public void run() { while(condition) { *code that must not be interrupted* *some more code* } } }).start(); SomeOtherThread.start(); YetAntherThread.start(); How can you ensure that code that must not be interrupted won't be interrupted? ...

In C# would it be better to use Queue.Synchronized or lock() for thread safety?

I have a Queue object that I need to ensure is thread-safe. Would it be better to use a lock object like this: lock(myLockObject) { //do stuff with the queue } Or is it recommended to use Queue.Synchronized like this: Queue.Synchronized(myQueue).whatever_i_want_to_do(); From reading the MSDN docs it says I should use Queue.Synchron...

Monitor .NET Threads

Is there any way to monitor/log thread interactions in the .NET runtime much like VisualVM does for Java? I don't have a specific need at the moment but I think it would be nice to see how all the threads in my application interact. ...

How do I ensure a value being updated with Hibernate hadn't been changed in the meantime since I read it?

I have a problem where I want to read an object from the database using Hibernate, change a value, and save the object. If changing the value takes some time, what's the best way to ensure the underlying object in the database has not changed? I am doing this in one transaction (and one session). The code looks something like: // Load...

Would ManualResetEvent/AutoResetEvent use workerthread or IO-thread in asp.net

the web layer is coded in asp.net with pages marked as async. Yes, the recommended way to code for aync is using the RegisterAsyncTask I have a problem now - there are a few pages that have used AutoResetEvent and ManualResetEvent for aync and not the standard RegisterAsyncTask. Would these objects servicing the async calls, use up th...

Calling a function from the main thread and making it working in paralel with a function in the main thread (part 2)

dear all; thnx for all your replays .. i tried your options and i want to ask if that was right and is are the 2 threads working in paralel or not.. and here is my code : // in the Form.Load() Timer1.Enabled = true; Timer1.Start(); if (InvokeRequired) { Invoke(new GetFromServerHan...

Tool to browse Multi-thread (C++/C) code ?

We are using multi-thread in our fairly large product, but when doing review we hardly know a function or method will run under which thread. I know this looks stupid, but in a large product without good modularization, we can lost. And there are many potential synchronization problems are aware of. So I'm wondering if there are tools f...

How can I debug with a single proc on a multi-proc system?

My development machine is a quad core system, but I just ran into ( and I am still debugging ), and problem when my application is deployed to single processor systems. I get a dead lock. I would like to be able to debug using only a single processor, rather than having to build a development VM to debug with. Is it possible to tell V...

How to delegate a method call to another thread ?

I have the following problem: Multithreaded WPF application, Model View Presenter Implementation. Presenters and Views that belong together are created on a separate thread and get a separate Dispatcher. Now someone calls from another thread a method on the Presenter. I am intercepting the call, and now begins the problem: if the call co...

What is the best practice for running a number of tasks (threads) with a single timeout (run for a max of 30 seconds across all threads)?

I came up with a solution, but I wanted to see if anyone had a better way or more standard way of doing this. The main method demonstrates how I would use this class. In a production version of this I would keep the thread pool open and continue to reuse it rather than shut it down after the calls. public class MultiCallManager<T> { p...

Which is the better method? Allowing the thread to sleep for a while or deleting it and recreating it later?

We have a process that needs to run every two hours. It's a process that needs to run on it's own thread so as to not interrupt normal processing. When it runs, it will download 100k records and verify them against a DB. The framework to run this has a lot of objects managing this process. These objects only need to be around when th...

Is calling AsyncOperation.PostOperationCompleted required?

I'm using the AsyncOperation class to avoid having to write tons of "if (control.InvokeRequired) then/else" methods (as opposed to its traditional role in the Event-Based Asynchronous Pattern). In some cases, I don't really care about getting a notification when the worker thread is complete. Because of this, I'd like to not call the P...

Java: Run a Callable in a separate process

Given an instance x of Callable<T>, how can I run x in a separate process such that I can redirect the standard input and output of the process? For example, is there a way to build a Process from a Callable? Is there a standard Executor that gives control over input and output? [UPDATE] It's not important that the Callable execute in a...

GUI Locking up when using PrintDialog and PrintPreviewDialog in .net

I'm using .net's PrintPreviewDialog and whenever it's generating a preview, it locks up my GUI in the background and makes it look like it has crashed until the preview is finished. Seeing how the .net's page progress window that pops up isn't a dialog, the back ground can be selected which then comes to the front in a half drawn, locked...

Simple Asynchronous Multi-Threaded HTTP request library for C++

I'll be quick and honest: I'm currently trying to write a client/server for an online game. Since I'm poor and limited on resources, I'll be testing the bare basics of the server using a PHP backend, with the eventual goal being to rebuild the server end in C++. I'm looking for a C++ library for Windows (XP and Vista preferably) that wi...

How can I make my server have open connections to multiple clients at the same time?

I want to write my own little chat server in C on a MacOS machine. Now I want to connect to all clients, that are online and let the connection open, to be able to receive and send messages. The problem is that I only know, how to have one socket connection at a time open. So only one client can connect so far and chatting like that is k...

Multithreading using the boost library

Wish to simultaneously call a function multiple times. I wish to use threads to call a function which will utilize the machines capability to the fullest. This is a 8 core machine, and my requirement is to use the machine cpu from 10% to 100% or more. My requirement is to use the boost class. Is there any way I can accomplish this usi...

Maximum number of threads per process in Linux?

What is the maximum number of threads that can be created by a process under Linux? How (if possible) can this value be modified? ...

Is there anything like OpenMP on Java?

Is there anything like OpenMP on Java? ...

Thread and Process

What is the best definition of a thread and what is a process? If I call a function, how do I know that a thread is calling it or a process (or am I not understanding it??!). This is in a multi-core system (quadcore). ...