multithreading

Java3D getting time problem

Hi, I made a little Shooter game with two ships firing at each other. I used methods of paintComponent for drawing or moving object, but for some reason it ran at a different speed on each computer. I searched for a solution and made some modifications to my game like drawing and moving objects in thread. Now it runs at the same speed ...

how to predict which section have to put in critical section in threading

Hi , I am using the console application i used multi threading in the same. I just want to know which section have to put inside critical section my code is : .------------------------------------------------------------------------------. public class SendBusReachSMS { public void SchedularEntryPoint() { try ...

What is critical section in threading?

Please can some one briefly tell me with example what does the means of critical section? in simple language ...

what is difference between fork and thread

Hi All, Can you any one explain me about what is difference between fork and thread ..? Thanks ...

What will or won't cause a thread to block (a question from a test)

I've had a test, and there was a question I lost some points on, because I wasn't able to answer it : Which of the following is NOT a condition which can cause a thread to block : Calling an objects's wait() method Waiting for an I/O operation Calling sleep() Calling yield() Calling join() As far as I know, all of these are blo...

Pause and resume thread drawing to SurfaceView

I am developing a chess game for Android (http://androidchess.appspot.com), using SurfaceView for the chessboard. I have a drawing Thread, that draws the chessboard in a loop. The problem is that when there are no active animations (this is more that 90% of time), it makes no sense to waste CPU and battery for drawing. How should I solve...

Python: Script works, but seems to deadlock after some time

I have the following script, which is working for the most part Link to PasteBin The script's job is to start a number of threads which in turn each start a subprocess with Popen. The output from each subprocess is as follows: 1 2 3 . . . n Done Bascially the subprocess is transferring 10M records from tables in one database to diff...

How does the event dispatch thread work?

With the help of people on stackoverflow I was able to get the following working code of the simples GUI countdown (it just displays a window counting down seconds). My main problem with this code is the invokeLater stuff. As far as I understand the invokeLater send a task to the event dispatching thread (EDT) and then the EDT execute t...

What is the event dispatching thread?

I know what "thread" means and if I understand the event dispatching thread (EDT) as "just a thread", it explains a lot but, apparently, it does not explain everything. I do not understand what is special about this thread. For example I do not understand why we should start a GUI in a the EDT? Why the "main" thread is bed for GUI? We...

questions about multi threading for sockets/tcp-connections.

I have a server that connects to multiple clients using TCP/IP connections, using C in Unix. Since it won't have more than 20 connections at a time, I figured I would use a thread per connection/socket. But the problem is writing to the sockets as I'll be sending user prompted msgs to clients. Once each socket is handled by a thread, how...

Why is volatile not considered useful in multithreaded C or C++ programming?

As demonstrated in this answer I recently posted, I seem to be confused about the utility (or lack thereof) of volatile in multi-threaded programming contexts. My understanding is this: any time a variable may be changed outside the flow of control of a piece of code accessing it, that variable should be declared to be volatile. Signal...

What are shared by multi threads in the same process?

I found that each thread still has its own registers. Also has its own stack, but other threads can read and write the stack memory. My questions, what are shared by the multi threads in the same process? What I can imagine is 1) address space of the process; 2) stack, register; 3) variables Can any body elaborate it and add more? ...

Gracefully exiting from thread in Ruby

Hi, I am trying out Mongrel and using the following code: require 'rubygems' require 'mongrel' class SimpleHandler < Mongrel::HttpHandler def process(request, response) response.start(200) do |head, out| head["Content-Type"] = "text/plain" out.write("Hello World!\n") end end end h = Mon...

What the difference between deadlock avoidance and deadlock prevention?

I met two terms and are they the same thing or different thing? ...

Accessing UI thread of a form?

I'm using C# and I'm making an application where a lot of UI loading must be done in background. Is it possible to do it unsafely and ignore InvalidOperationExceptions? The only way I found it to put try...catch statements around every single line of code but this will take ages as there is too much code. ...

Whats wrong with my backgroundwork method

I am trying to get a background worker process working in a wpf application. it creates 2 files then crashes. BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += delegate(object s, DoWorkEventArgs args) { CreateFile(i.ToString()); ...

Should I thread this?

I've got a "Loading Progress" WPF form which I instantiate when I start loading some results into my Main Window, and every time a result is loaded I want the progress bar to fill up by x amount (Based on the amount of results I'm loading). However what happens is that the Progress bar in the window stays blank the entire time, until th...

Is it a good way to close a thread?

I have a short version of the question: I start a thread like that: counter.start();, where counter is a thread. At the point when I want to stop the thread I do that: counter.interrupt() In my thread I periodically do this check: Thread.interrupted(). If it gives true I return from the thread and, as a consequence, it stops. And h...

Why can't I use/cast an Action for/to a ThreadStart?

Both are delegates and have the same signature, but I can not use Action as ThreadStart. Why? Action doIt; doIt = () => MyMethod("test"); Thread t; t = new Thread(doIt); t.Start(); but this seams to work: Thread t; t = new Thread(() => MyMethod("test")); t.Start(); ...

Java Backgroundworker: Scope of Widget to be updated unclear

Hi all, I am trying to understand the mechanism of org.jdesktop.swingx.BackgroundWorker. Their javadoc presents following example: final JLabel label; class MeaningOfLifeFinder implements BackgroundListener { public void doInBackground(BackgroundEvent evt) { String meaningOfLife = findTheMeaningOfLife(); ...