I have two designs for an instant message program that I'm writting in Java
The first idea uses 2 separate threads. The first thread overlooks the gui and sends out the instant message data through writing to a blocking socket. The 2nd thread uses another blocking socket to monitor for incoming packets from the friend. I'm not certain if using threads is the best way to approach this problem, but I find it to be easier to deal with than using non-blocking socketchannels.
The 2nd design that I have is to use non-blocking socket channels in one thread which will occasionally check to see if there is incoming or outgoing data. The nice thing about this design is that I don't have to worry about resource sharing among threads, but I'm not sure if its more efficient.
Honestly, all I really care about is making a program that runs smoothly and efficiently. What do you think would be a more efficient and easier design to build? I'm just playing around so I have no experience in building efficient and powerful client/server programs other than what my senses tell me.