Topic awaiting preservation: Java Thread's Wait For Input etc. (Page 1 of 1) |
|
---|---|
Maniac (V) Mad Scientist From: 100101010011 <-- right about here |
posted 02-04-2005 20:52
Alright I have a Java prog that I've set up that can communicate with a Jabber Server (IM). Essentially I'm writing an IM bot. I haven't used a lot of Java but I'm using it on this project a lot so I think this is where I come up to speed. |
Maniac (V) Mad Scientist From: Rochester, New York, USA |
posted 02-04-2005 21:38
Try doing a searh for "java notify threads" or something similar. I would write more on this but I have a plane to catch. |
Paranoid (IV) Mad Scientist with Finglongers From: Germany |
posted 02-05-2005 13:03
look if the select function is available in java. That's the way to handle such things in C and basically every unixy language I have run across (windows supports it too). |
Maniac (V) Mad Scientist From: Rochester, New York, USA |
posted 02-07-2005 18:16
After another look with some more time I am a bit confused, I think you might have something like: |
Maniac (V) Mad Scientist From: 100101010011 <-- right about here |
posted 02-07-2005 21:12
The main issue I'm running into is keeping the main thread running while I wait for new connections. It seems like more overhead than I need to do a while(true) loop when really I just want to act when a new packet comes in. (This is based on no technical knowlege just sheer guessing) |
Paranoid (IV) Mad Scientist with Finglongers From: Germany |
posted 02-07-2005 22:52
I don't get your problem? |
Maniac (V) Mad Scientist From: Rochester, New York, USA |
posted 02-07-2005 23:02
Ok, so I was close? |
Maniac (V) Mad Scientist From: 100101010011 <-- right about here |
posted 02-08-2005 00:00
First I'm letting the Jabber API handle the socket connection. So I'm trying not to hack that part of the script. Jabber implements the XMPP protocol on top of the socket connection so there's a lot if handling in there that I don't want to mess with. (Plus I'm pretty sure I shouldn't have to). code: // Imports missing for brevity.
|
Maniac (V) Mad Scientist From: 100101010011 <-- right about here |
posted 02-08-2005 01:58
Hmm I may be going about this wrong it's starting to look like a Thread can't interrupt or pause itself I may need to do some hacking of the API to do this properly. (I pass this class to the XMPP Connection so I'm not calling it myself) |
Maniac (V) Mad Scientist From: 100101010011 <-- right about here |
posted 02-08-2005 02:12
Alright I think I'm an idiot. I'm trying to make this application as efficient as possible so I was afraid of the sleep command thinking that it would create pauses between calls to the processPacket method. |
Maniac (V) Mad Scientist From: Rochester, New York, USA |
posted 02-08-2005 06:53
That is really weird looking. I am guessing that the handling of the class is done in process packet, but I can't for the life of me figure out where you are calling it from. Your thread loop is null, has nothing in it, so I am wondering why you have this setup as a thread. When you call Thread.run() it isn't going to do anything. |