File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Thread Not Starting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Thread Not Starting" Watch "Thread Not Starting" New topic

Thread Not Starting

Alex Kirk
Ranch Hand

Joined: Aug 13, 2001
Posts: 44
I've been working on a network app for a while now that uses a class, connectionManager, which runs as a thread and processes inbound and outbound DatagramPackets. It's been behaving progressively more oddly on me the last few days, it's to the point that it's driving me nuts.
On a theoretical level, I know that if I have a class that "extends Thread", whose constructor creates a socket and whose run() method is a while(true) loop, that that class should be able to process all inbound and outbound packets on that socket. Thankfully, outbound packets work just great.
But when I instantiate an object of this class, and then call obj.start(), I'm not receiving anything on this socket (or at least the run() method isn't doing anything with the data that might come in).
Confusing me further are the facts that a) I didn't change anything from the time this worked to now, at least that's related to inbound data packets; and b) if I call directly, the program receives data just fine.
To see the files in question, go to (the calling, main file) and (the thread implementation). If you want to try running the program, grab and follow the instructions in the README file.
Thanks for your help.
Alex Kirk
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

It sounds like what you are doing is creating a Listener to listen to a port, or Socket, and you want the thread to act as the listener. This is called a Daemon thread. and the Thread class has a method called setDaemon(boolean), or is it isDaemon(boolean). Well it's one or the other and you can look it up in the Help for JAva API.

Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
I agree. Here's the link:
subject: Thread Not Starting
It's not a secret anymore!