multithreading

Java - Thread problem

My question is related to all those methods(including Thread.sleep(...)) which throw InterruptedException. I found a statement on Sun's tutorial saying InterruptedException is an exception that sleep throws when another thread interrupts the current thread while sleep is active. Is that means that the interrupt will be ignored if ...

Java: Is catching exceptions asynchronous?

I am asking because if it is not, it can be abused as synchronizations mechanism. I am asking about Java. ...

Java - Thread - Problem in one of the Sun's tutorial

I was reading this Sun's tutorial on Thread. I found a block of code there which I think can be replaced by a code of fewer lines. I wonder why Sun's expert programmers followed that long way when the task can be accomplished with a code of fewer lines. I am asking this question so as to know that if I am missing something that the tut...

Accessing global variable in multithreaded Tomcat server

Edit: I've figured out the constructor for the singleton is getting called multiple times so it appears the classes are getting loaded more than once by separate class loaders. How can I make a global singleton in Tomcat? I've been googling, but no luck so far. I have a singleton object that I construct like thus: private static volati...

How do I read user input in python thread?

I'm trying to read from a thread in python as follows import threading, time, random var = True class MyThread(threading.Thread): def set_name(self, name): self.name = name def run(self): global var while var == True: print "In mythread " + self.name time.sleep(random.randint(2,...

How to read large number of files using multiple threads,help me please!

Hello all,in my application there is a small part of function,in which it will read files to get some information,the number of filecount would be utleast 50,So I thought of implementing threading.Say if the user is giving 50 files,I wanted to separate it as 5 *10, 5 thread should be created,so that each thread can handle 10 files which ...

Is udev thread-safe?

I'd like to know if there are dangers with spawning multiple threads that each create their own udev context and start monitoring hardware changes. It would think that if each thread has its own udev context everything is fine. However, if calls like udev_new or udev_monitor_new_from_netlink would access global/static variables then issu...

Threading multiple WebBrowser in VB .net

I'm building a multiple webbrowser inside tabs( 1 predefine webbrowser control per tab) and I want them all to load at the same time or other words must run in thread. Unfortunately I feel a valid fact came from the error message that this is something not possible. Pls help me to check my simple program code below and its error in case ...

ExecutorService that interrupts tasks after a timeout

I'm looking for an ExecutorService implementation that can be provided with a timeout. Tasks that are submitted to the ExecutorService are interrupted if they take longer than the timeout to run. Implementing such a beast isn't such a difficult task, but I'm wondering if anybody knows of an existing implementation. Here's what I came up...

Debug.WriteLine locks

My program frequently stops with a deadlock. When I do a break-all and look at the threads I see that three threads are stuck in our logging function: public class Logging { public static void WriteClientLog(LogLevel logLevel, string message) { #if DEBUG System.Diagnostics.Debug.WriteLine(String.Format("{0} {1}", Dat...

How to identify deadlock conditions in a third-party application?

I am using a third-party application to handle batch CD audio extraction via multiple FireWire attached devices, but the application frequently (though non-deterministically) hangs during the extraction. I suspect that the multithreaded application is deadlocking over some shared resource. The developer, however, suspects the problem lie...

Java Thread - Memory consistency errors

I was reading a Sun's tutorial on Concurrency. But I couldn't understand exactly what memory consistency errors are? I googled about that but didn't find any helpful tutorial or article about that. I know that this question is a subjective one, so you can provide me links to articles on the above topic. It would be great if you explai...

Does [UIWebView loadRequest] block the thread?

I've read up on UIWebView and can't find a specific answer to whether or not it can block a thread when loadRequest is called (like NSURL can). I've heard that there is a specific UIWebView thread that all UIWebView's try to load using (and as a result that thread will be blocked with a slow load), but will there be any effect on the mai...

Java Thread - Synchronization issue

From Sun's tutorial: Synchronized methods enable a simple strategy for preventing thread interference and memory consistency errors: if an object is visible to more than one thread, all reads or writes to that object's variables are done through synchronized methods. (An important exception: final fields, which cannot be modified aft...

[C# Thread] I'd like access to a share on the network!

Some Details I am working with VisualWebGUI, so this app is like ASP.NET, and it is deployed on IIS 7 (for testing) For my 'Web Site', Anonymous Authentication is set to a specific user (DomainName\DomainUser). In my web.config, I have impersonation on. This is how I got my app to access the share in the first place. The Problem T...

My multithread program works slowly or appear deadlock on dual core machine, please help

I have a program with several threads, one thread will change a global when it exits itself and the other thread will repeatedly poll the global. No any protection on the globals. The program works fine on uni-processor. On dual core machine, it works for a while and then halt either on Sleep(0) or SuspendThread(). Would anyone be able ...

Are there any nasty side affects if i lock the HttpContext.Current.Cache.Insert method

Apart from blocking other threads reading from the cache what other problems should I be thinking about when locking the cache insert method for a public facing website. The actual data retrieval and insert into the cache should take no more than 1 second, which we can live with. More importantly i don't want multiple thread potentiall...

Periodically iterating over a collection that's constantly changing

I have a collection of objects that's constantly changing, and I want to display some information about the contents every so often (my application is multi-threaded, and differently threads are constantly submitting requests to modify an object in the collection, so it's unpredictable). If I lock the collection, I can iterate over it a...

Is there a JVM aimed at debugging concurrent software?

I've used Concurrent Pascal, a tool which helps debug concurrent algorithms because when it runs your code, it randomizes which thread to swap to at every possible step, trying out as many paths as possible. Is there a JVM that can do this? ...

How to use CriticalSection - MFC?

I' am working on a small example and am a bit of curious using criticalsection in my example. What I'am doing is,I have a CStringArray(which has 10 elements added to it).I want to copy these 10 elements(string) to another CStringArray(am doing this to understand threading and Critical section),I have created 2 threads,Thread1 will copy ...