• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Thread Not Starting

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 obj.run() directly, the program receives data just fine.
To see the files in question, go to www.schnarff.com/gnutonic/runGnutonic.java (the calling, main file) and www.schnarff.com/gnutonic/connectionManager.java (the thread implementation). If you want to try running the program, grab www.schnarff.com/gnutonic/gnutonic-0.1.1.tgz and follow the instructions in the README file.
Thanks for your help.
Alex Kirk
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
Mark
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic