multithreading

What is the meant by 'thread safe' object?

I have used generic queue in C# collection and everyone says that it is better to use the object of System.Collection.Generic.Queue because of thread safety. Please advise on the right decision to use Queue object, and how it is thread safe? ...

What is the Mutex and semaphore In c#? where we need to implement?

What is the Mutex and semaphore In c#? where we need to implement? How can we work with them in multithreading? ...

java.lang.IllegalMonitorStateException: (m=null) Failed to get monitor for

Why may this happen? The thing is that monitor object is not null for sure, but still we get this exception quite often: java.lang.IllegalMonitorStateException: (m=null) Failed to get monitor for (tIdx=60) at java.lang.Object.wait(Object.java:474) at ... The code that provokes this is a simple pool solution: publi...

Exception handling in threads

Recently i have attended an interview . A code snippet is given to me.I know,the interviewer took it from albhari's threading sample. public static void Main() { try { new Thread (Go).Start(); } catch (Exception ex) { // We'll never get here! Console.WriteLine ("Exception!"); } static void Go() { throw null; } } The modific...

Thread.Sleep(0) will give up acquired CPU resource ?

When i specifiy the time interval zero static void Main() { Thead.Sleep(0); } would the Main() thread give up the CPU resource it acquired or without waiting will it continue? ...

Is Queue.Peek thread safe?

A read operation on a 32 bit field is atomic. So if the queue holds object references the Queue.Peek method should be thread safe, right? ...

implement thread for consuming operations in Qt

Hello, I have never worked with QThread in Qt, or with threads in general, so the topic is more then new to me. Still I have to use QThread's in order to avoid the blocking of my main application due to some heavy computations. So I want to put my heavy computations in a thread and if they take too much time I want to kill the thread (...

Thread lock clarification

I am a beginer in programing. When i execute the code by locking the operation: class ThreadSafe { static List<string> list = new List<string>(); static object obj=new object(); static void Main() { new Thread(AddItems).Start(); new Thread(AddItems).Start(); foreach (string str in list) ...

QThread issues. Crash after 2058 runs.

Following thread code runs 2058 times, after that it crashes. Can somebody help me figure out why? The idea of the program is create some class in main thread, pass it to worker thread, thread fills needed data and pass data back to main thread. This example crashes after 2058 runs, however it should go indefinately. I've run it 20 times...

VB.net simple threaded GUI based program. Where to put the thread

I have written a small GUI based vb.net program that speaks to embedded devices via the com port. The GUI code contains a class which all communication to the embedded device is handled through (com port device, communication protocol, parsing info, holding device related info after each read).That class is called EDComms. I wanted to a...

Progressdialog slow to show in Android

Hi all, I'm sure this is a simple threading issue but... I'm starting a ProgressDialog using: ProgressDialog.show(Example.this, " " , " Loading. Please wait ... ", true,true); Then running a block of code to download and parse XML. The problem I'm having is that this is all running under a onClick button method, and that the xml is ...

Difference between Abort and Interrupt in Threads in .NET

What is the difference between Thraed.Abort() and Thread.Interrupt(). How can I call them in a Thread Safe Manner.It would be helpful,if simple example is provided. ...

Does SQLite write operation block database only for other processes or for threads of single process too?

Does SQLite write operation block database only for other processes or for threads of single process too? Is it possible to use SQLite in multithreading (=multisession) ASP.Net application? ...

C#: Can't I use an anonymous delegate in ThreadStart?

Can't I have an anonymous delegate declaration, something similar to the following: ThreadStart starter = delegate() { go(); }; ... static void go() { Console.WriteLine("Nice Work"); } // (or) ThreadStart starter=delegate() { Console.WriteLine("Hello");} ...

partial page source from httpwebresponse

I am very new to this so please pardon any ignorance. I have created my first multi-threaded application and it's purpose is to make numerous webrequests, parse each page source, and store the results in tables for further interrogation. Theoretically there could be as many as 30-40000 requests, therefore the need to multi-thread. Each...

How to convince my co-worker the linux kernel code is re-entrant ?

Yeah I know ... Some people are sometimes hard to convince of what sounds natural to the rest of us, an I need your help right now SO community (or I'll go postal soon ..) One of my co-worker is convinced the linux kernel code is not re-entrant as he reads it somewhere last time he get insterested in it, likely 7 years ago. Probably its...

What are the important threading API calls to understand before writing multi-threaded code?

Recently I was blogging about the oft over-used idea of multi-threading in .Net. I put together a staring list for "APIs you should know first": Thread ThreadPool ManualResetEvent AutoResetEvent EventWaitHandle WaitHandle Monitor Mutex Semaphore Interlocked BackgroundWorker AsyncOperation lock Statement volatile ThreadStaticAttribute ...

Multithreading on Windows Forms

I want to paralelize a 3D voxel editor built on top of Windows Forms, it uses a raycaster to render so dividing the screen and getting each thread on a pool to render a part of it should be trivial. The problem arises in that Windows Forms' thread must run as STA - I can get other threads to start and do the work but blocking the main t...

Fundamental difference between Join() Lock()

For the case of both Join() and lock() one thread can execute after the other.What is the main difference? ...

How Can I Avoid Invoking Every Event From My External Library?

I've written a library which handles all the TCP/IP comms with our custom embedded hardware. It is used with most of our in house software and in the future could possibly be sold separately. The most annoying thing this is that every time I handle events from the library, I have to have a seperate function to invoke through. I can only...