Multiple things at once (Threads?)

Posted by Jonathan on Stack Overflow See other posts from Stack Overflow or by Jonathan
Published on 2010-04-01T23:47:18Z Indexed on 2010/04/01 23:53 UTC
Read the original article Hit count: 211

Filed under:
|

All,

What is a really simple way of having a program do more than one thing at once, even if the computer does not necessarily have multiple 'cores'. Can I do this by creating more than one Thread?

My goal is to be able to have two computers networked (through Sockets) to respond to each-other's requests, while my program will at the same time be able to be managing a UI. I want the server to potentially handle more than one client at the same time as well.

My understanding is that the communication is done with BufferedReader.readLine() and PrintWriter.println(). My problem is that I want the server to be waiting on multiple readLine() requests, and also be doing other things. How do I handle this?

Many thanks,

Jonathan

© Stack Overflow or respective owner

Related posts about java

Related posts about multithreading