multithreading

Multi-Tier Application in .NET

Hello, I am still learning .NET framework and I want to implement multi-tier application just for practice. I was wondering what is the best way to achieve that. My goal is to make application for hospitals. What is my question? Is it good idea to implement multithreaded server that accepts client requests via sockets. Worker threads...

C++: synchronize 5 consumers to 1 producer (multithreaded)

Hi all, I have five consumers and one producer. The five consumers each output different data, from the one producer, for ~10ms. During those 10ms the producer prepares the parameters for the next output. When the output parameters are set, I want to set a flag instructing the consumers to begin the next output. I only want the producer...

Java, Design pattern : Multiple event sources and One event Handler

Hello everybody, I want to implement a design in Java where I have multiple event sources (Threads). Such event source accomplish a specific task and had to notify the unique Event Handler (Class) and this one have to accomplish other tasks according to event sources notifications. My question is : how to implement this desiqn in the a...

Can you suspend a Java app and get a snapshot of it's threads from within the app?

I'm looking at writing monitoring code that runs inside a Java application and periodically takes a snapshot of running threads and displays some call stack information on each. Ideally this would be extended for profiling and/or monitoring. I don't want to use an external tool, as this is for self educational purposes. ...

"start /affinity" equivalent in .NET

The start Windows shell command (in cmd.exe) appears to be able to start a process with a chosen processor affinity, rather than starting the process then setting the chosen processor affinity some (small) period of time after it has started. start /affinity 2 something.exe Is there a way to do the same from within a .NET application ...

Java logging across multiple threads

Hi, We have a system that uses threading so that it can concurrently handle different bits of functionality in parallel. We would like to find a way to tie all log entries for a particular "transaction" together. Normally, one might use 'threadName' to gather these together, but clearly that fails in a multithreaded situation. Short o...

Multithreading in Lua

I was having a discussion with my friend the other day. I was saying how that, in pure Lua, you couldn't build a preemptive multitasking system. He claims you can, because of the following reason: Both C and Lua have no inbuilt threading libraries [OP's note: well, Lua technically does, but AFAIK it's not useful for our purposes]. Wind...

Multi-threaded library calls in ASP.NET page request.

I have an ASP.NET app, very basic, but right now too much code to post if we're lucky and I don't have to. We have a class called ReportGenerator. On a button click, method GenerateReports is called. It makes an async call to InternalGenerateReports using ThreadPool.QueueUserWorkItem and returns, ending the ASP.NET response. It doesn...

Async networking + threading problem

I kick off a network request, assuming no login credentials are required to talk to the destination server. If they are required, then I get an authentication challenge, at which point I display a view requesting said credentials from the user. When they are supplied, I restart the network request, using those credentials. That's all ...

Millisecond-Accurate Scheduling of Future Events in C++/CLI

I need to create a C++/CLI mixed assembly that can schedule future calls into a native DLL with millisecond accuracy. This will, of course, mean setting a timer (what kind?) for a millisecond or three beforehand, then spinning until the moment and calling the native DLL function. Based on what I've read, I would guess that the callba...

How to manage db connections on server?

I have a severe problem with my database connection in my web application. Since I use a single database connection for the whole application from singleton Database class, if i try concurrent db operations (two users) the database rollsback the transactions. This is my static method used: All threads/servlets call static Database.doSom...

Boost threading/mutexs, why does this work?

Code: #include <iostream> #include "stdafx.h" #include <boost/thread.hpp> #include <boost/thread/mutex.hpp> using namespace std; boost::mutex mut; double results[10]; void doubler(int x) { //boost::mutex::scoped_lock lck(mut); results[x] = x*2; } int _tmain(int argc, _TCHAR* argv[]) { boost::thread_group thds; for (int x = 10; x>0...

Multithreaded Win32 GUI message loop

When do you need to use this type of modified message loop in multithreaded application? DWORD nWaitCount; HANDLE hWaitArray[4]; BOOL quit; int exitCode; while (!quit) { MSG msg; int rc; rc = MsgWaitForMultipleObjects(nWaitCount, hWaitArray, FALSE, INFINITE,QS_ALLINPUT); if (rc == WAIT_OBJECT_O + nWaitCount) { whi...

Swing and handling threads

There's a couple questions here on StackOverflow on the subject of threading with the Swing api but things still aren't clear. What is the issue with the EDT, what is the proper way to initiate a Thread with Swing and in what cases should it be used? P.S: Any sources in terms of good practises would be appreciated. ...

Thread safe collections in .NET

What is the standard nowadays when one needs a thread safe collection (e.g. Set). Do I synchronize it myself, or is there an inherently thread safe collection? ...

Why isn't it possible to update an ObservableCollection from a different thread?

In a multi-threaded WPF application, it is not possible to update an ObservableCollection from a thread other than WPF window thread. I know there are workarounds, so my question is not how to avoid the "This type of CollectionView does not support changes to its SourceCollection from a thread different from the Dispatcher thread" excep...

Find TableLeyout in a thread (Because of the ProgressDialog)

Hi all, On my activity, im getting some big data from web, and while getting this data i want to show the user a ProgressDialog with spinning wheel. That i can do only with putting this code into a thread, right ? the problem is that after im getting this data i need to insert it into my tableLayout as TableRows and it seems impossible ...

java Sockets and Threads Problem

I am doin a Some Socket Programing Stuff in Java.. Here i have created a button(Create Server)..and when i click it ,it starts server...but i want to change the button name to (Stop Server) after Starting the server... so i did this.. but when i press start server it starts and the button name remains the same... and when a client gets ...

Can I ensure that Haskell performs atomic IO?

I have two threads in haskell that perform IO. (They print only). Something like the following: thread1 :: IO () thread1 = putStrLn "One" thread2 :: IO () thread2 = putStrLn "Two" I am currently getting results like the following: OnTwoe OTnweo How can I ensure that each thread completes its IO atomically? ...

UIActivityView and blocking

Hello, I have a section of code that uploads an image: [activity startAnimating]; [self uploadImage:img Session_id:appDelegate.sessionID PlaceID:place.placeID Comment:comment.text]; [activity stopAnimating]; I am sure that activity is wired up correctly to a UIActivityViewIndicator, but it never shows. Inside the uploadImage functi...