multithreading

Thread help with Android game

I need some help dealing with three Threads in Android One thread is the main thread, the other is the GLThread, and the other is a WorkerThread I created to update the game state. The problem I have is they all need to access the same LinkedList of game objects. Both the GLThread and my WorkerThread only read from the LinkedList, so ...

How to check how many threads are waiting for a synchronized method to become unlocked

Is there any way to check how many threads are waiting for a synchronized method to become unlocked? I would like to know when the thread calls a synchronized method: 1) How many threads are already waiting to call the method? 2) Once the method is called how long it needed to wait for the method to become unlocked? Solution: I sol...

Put Java Threading Class into a separate class

Consider following SWT code example: http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet151.java?view=co How can I separate the inline defined class? Thread thread = new Thread() { public void run() { ... } }; I want to define a separate class which u...

Java Performance measurement

Hi, I am doing some Java performance comparison between my classes, and wondering if there is some sort of Java Performance Framework to make writing performance measurement code easier? I.e, what I am doing now is trying to measure what effect does it have having a method as "synchronized" as in PseudoRandomUsingSynch.nextInt() compar...

Why the following Java code has different outputs each time?

I don't know about threads in Java. I like to know what is happening in this code because each time it runs, it produces a different output: public class TwoThreadsDemo{ public static void main(String[] args) { new SimpleThread("Java Programmer").start(); new SimpleThread("Java Programmer").start(); } } clas...

Filling SWT table object using a separated thread class ...

Hi all I've got a code snippet by the swt team that does exactly what I need. However, there is a part I want to separate into another class, in particular, the whole inline stuff. In response to my former question, it has been suggested that Callable should be used in order to implement threaded objects. It is suggested to make use of ...

OpenCV and Cocoa error "Previous frame inner to this frame"

Hello every body! I'm playing with OpenCV in Cocoa program. When I try to call the method with some OpenCV code in the second thread I get "Previous frame inner to this frame (gdb could not unwind past this frame)" ...

Why does my ActivePerl program report 'Sorry. Ran out of threads'?

Tom Christiansen's example code (à la perlthrtut) is a recursive, threaded implementation of finding and printing all prime numbers between 3 and 1000. Below is a mildly adapted version of the script #!/usr/bin/perl # adapted from prime-pthread, courtesy of Tom Christiansen use strict; use warnings; use threads; use Thread::Queue; su...

JScrollPane Scrolls Down with Long Text in JEditorPane

Hello, I want to have a JEditorPane inside a JScrollPane. When the user clicks a button, the click listener will create a textEditor, call jscrollpane.setViewPort(textEditor), call textEditor.setText(String) to fill it with editable text, and call jscrollpane.getVerticalScrollBar().setValue(0). In case you're wondering, yes, the setTe...

Is there a timeout for threads waiting on a synchronised method in Java?

Is there a default timeout for threads waiting on a synchronised method in Java? Some threads in my app are not completing as expected. Is there anyway to check whether threads have died as a result of timeouts? ...

How do I prove whether or not a dining philosophers suffers from deadlock or starvation possibilities? Where to start?

Hi, I have a homework task to prove whether or not a particular variation on the dining philosophers problem suffers from deadlock or starvation. I suspect that the situation does not suffer at all from either but I'm finding this tricky to prove and I don't really know where to start. Is there a general strategy for attacking this so...

Make Python Socket Server More Efficient

I have very little experience working with sockets and multithreaded programming so to learn more I decided to see if I could hack together a little python socket server to power a chat room. I ended up getting it working pretty well but then I noticed my server's CPU usage spiked up over 100% when I had it running in the background. He...

in ASP.Net, are long running static operations a bottleneck?

If a long running operation is defined in a frequently called static method, is it a bottleneck for other threads in an ASP.Net application trying to call the same method? Does that only apply to methods with the "Synchronized" attribute>? I've searched and can't seem to find a definitive answer. ...

How do I make my ArrayList Thread-Safe? Another approach to problem in Java?

I have an ArrayList that I want to use to hold RaceCar objects that extend the Thread class as soon as they are finished executing. A class, called Race, handles this ArrayList using a callback method that the RaceCar object calls when it is finished executing. The callback method, addFinisher(RaceCar finisher), adds the RaceCar object t...

Python sock.listen(...)

All the examples I've seen of sock.listen(5) in the python documentation suggest I should set the max backlog number to be 5. This is causing a problem for my app since I'm expecting some very high volume (many concurrent connections). I set it to 200 and haven't seen any problems on my system, but was wondering how high I can set it bef...

How to control a subthread process in python?

Code first: '''this is main structure of my program''' from twisted.web import http from twisted.protocols import basic import threading threadstop = False #thread trigger,to be done class MyThread(threading.Thread): def __init__(self): threading.Thread.__init__(self) self.start() def run(self): whi...

What threading analysis tools do you recommend?

My primary IDE is Visual Studio 2005 and I have a large C/C++ project. I'm interested in what thread analysis tools are recommended. By that I mean, I want a tool, static or dynamic, to help find race conditions, deadlocks, and the like. So far I've casually researched the following: 1. Intel Thread Checker: I don't believe that it...

Basic Java Multi-Threading Question

When an object is instantiated in Java, is it bound to the thread that instantiated in? Because when I anonymously implement an interface in one thread, and pass it to another thread to be run, all of its methods are run in the original thread. If they are bound to their creation thread, is there anyway to create an object that will run ...

Does operator new allocate on THREAD heap?

My problem seems to be this: heap data allocated by one thread (that later dies) seems to die as well. As so: Thread X: starts Thread Y: starts Thread X: ptr = new some bytes Thread X: dies Thread Y: tries to use ptr - and crashes! So far, I've only seen this problem on Darwin (Mac OS 10.5 and 10.6), but haven't tried more other plat...

How can i get a list of currently running threads in objective-C(iphone)

Is there a way to get the list of currently running threads in objective-C? I'm mostly interested in getting the NSThreads objects, cause i want to replace the assertion handler for each running thread? If such thing is not possible, maybe i could set my own selector to be invoked after any thread is spawn(so that i could do the asserti...