multithreading

What are the compiler, CLR or CPU optimizations to be aware of when working with threads and non-blocking synchronization?

As the title says, what are the compiler, CLR or CPU optimizations to be aware of when working with threads and non-blocking synchronization? I have read a little about the reordering of instructions to improve efficiency that could break things, and caching optimizations that will result in variables not being visible to other threads ...

python web crawler with thread support

Hello all, these day im making some web crawler script, but one of problem is my internet is very slow. so i was thought whether is it possible webcrawler with multithreading by use mechanize or urllib or so. if anyone have experience ,share info much appreciate. i was look for in google ,but not found much useful info. Thanks in advanc...

C# - Moving files - to queue or multi-thread

I have an app that moves a project and its files from preview to production using a Flex front-end and a .NET web service. Currently, the process takes about 5-10 mins/per project. Aside from latency concerns, it really shouldn't take that long. I'm wondering whether or not this is a good use-case for multi-threading. Also, considering t...

Can a transaction have many threads?

Generally We have some business logic that is causing a bottle neck within a transaction. The business logic queries the database for a set of data (read only), processes it, and returns an object. This must be done many times with varying parameters in a given request. Can we theoretically break off each business logic call into a sepa...

How to kill deadlocked threads in Java?

I'd like to kill threads that are stuck in deadlock state. First, we can detect thread ids in deadlock state using the findDeadlockedThreads() method of the ThreadMXBean class in java.lang.management. Then, I'd like to kill the threads by thread ids, and thus I have two related questions: (1) How to get the control of a thread by threa...

How to catch events in multi-threaded application that can be watched by main thread?

I have a console application (VB.NET). When it is started, it spawns worker threads to find work in the database and do the task, then look for the next task (A workflow basically). The problem that I have is that I have my Event Handler in the main thread that spawns the worker threads. Those workers, if they error, raise an event to a...

IllegalMonitorStateException

When running our program we get an exception of type java.lang.IllegalMonitorStateException. On Java6 API website, it says there is a constructor that gives a details about the exception: IllegalMonitorStateException(String s) How can we use this to get a better idea of where the bug is in our code? Is there anything else we can do (...

Berkeley DB in multithreaded applications

Hi, What is the best way to use berkeley DB (bdb) handles in a multi-threaded application? Is it better to have each thread open its own handle; or, is it better to open a single handle and have each thread do txn_begin { } txn->commit()? Which one scales better? I am using Transactional Data Store with DB_THREAD flag. Thanks ...

java synchronized block for more than 1 objects?

Hi, I have two arrays, and I need to synchronize access to them across threads. I am going to put them in a synchronized block. The problem is, I can pass only one of them to 'synchronized' st one go. How do I ensure that the access to both the arrays is synchronized? Do I put them in a class and create an object of it? Or I access th...

batching remote calls (to database or service)

Hi all, Hope some of you can give some pointers on this one. I generate code where i have to make calls to remote resources like webservices or databases. Consider this piece of code class Parent{ IEnumerable<Child> Children; int SumChildren() { // note the AsParallel return Children.AsParallel().Su...

Nested synchronized blocks on interned Strings

The title sounds like there is a lot of problems ahead. Here's my specific case: This is a travel tickets sales system. Each route has a limited quantity of tickets, and so purchasing the last ticket for a given route shouldn't be accessible to two people (a standard scenario). However, there is the "return ticket" option.. So, I'm usin...

C# volatile array items?

Hi I need an array with volatile items, and can't find a way to do that. private volatile T[] _arr; This means that the _arr reference is volatile, however it does not guarantee anything about the items inside the _arr object itself. Is there any way to mark the _arr's Items as volatile? Thanks. EDIT: The following code built acc...

Event Dispatch Thread meets the Java Memory Model

This is related to an earlier question I asked, where the answer was: If a field is accessed by multiple threads, it should be volatile or final, or accessed only with synchronized blocks. Otherwise, assigned values may not be visible to other threads. In addition anything that manipulates pixels on screen should be run f...

How to parallelize Sudoku solver using Grand Central Dispatch?

As a programming exercise, I just finished writing a Sudoku solver that uses the backtracking algorithm (see Wikipedia for a simple example written in C). To take this a step further, I would like to use Snow Leopard's GCD to parallelize this so that it runs on all of my machine's cores. Can someone give me pointers on how I should go a...

Raise unhandled exceptions in a thread in the main thread?

There are some similar questions, but none supply the answer I require. If I create threads via threading.Thread, which then throw exceptions which are unhandled, those threads are terminated. I wish to retain the default print out of the exception details with the stack trace, but bring down the whole process as well. I've considered...

What exactly is the difference between multi-threaded processing and parallel processing?

Single core CPUs or a machine with a single CPU cannot do parallel processing. True/false? In a single core single process CPU there can be only one thread's assembly instructions getting executed regardless of however many processes with however many threads are running (sleeping threads excluded) at any given time. True/False? Sorry...

Asynchronous operations on WriteableBitmap

I'm writing an application in WPF (C#) which does long operations on a collection of Bitmaps. To keep my application responsive, I decided to use another thread to perform the operations on bitmaps and report progress on a progressbar in main UI thread. I thought BackgroundWorker would do anything for me, but looks like it won't be that ...

Erlang and processes.

Hi all, I'm very new to Erlang and I'm currently reading Joe Armstrong's book, chapter 'concurrent programming'. I'm trying to run a list of processes to calculate if a number is a prime (naive method). But my code runs as if there was no processes. Both methods have the same duration. Where am I wrong ? shell.erl: c(prime). %a list ...

implementing kruskal's algorithm utilizing threads

I'm implementing Kruskal's algorithm and I'd like to utilize threads. However I am not sure I know enough about the algorithm to do this. What I imagine is that I'd different parts of the graph would be solved for and connected at the end. Can anyone point me in the right direction? Thanks. ...

BlackBerry - Does TimerTask run in the background?

Hello, Does TimerTask work even if my exit my application and come to home screen or explore other apps? I have read the forum and find out the thread kind of easy mechanism is to use TimerTask in BB. I want to have thread running always even my app is not launched(after first time), so that when an particular interval arrives, i can sh...