Multiple Threads

i have a network client/server game. i need an endless loop thread to constantly

listen to incoming connection requests AND another endless loop thread to

respond to clients mouse clicks, chat messages etc.

i can get them SEPARATELY to work but cant seem to get the applet

to start the 2nd thread.

what to do and where to put em.

[367 byte] By [seanbartholomew] at [2007-9-27 17:03:01]
# 1
Thread secondThread = new MyThread();secondThread.start();...class MyThread extends Thread{public void run(){for(;;){ // your second thread running here}}}
Ragnvald at 2007-7-6 11:27:37 > top of Java-index,Other Topics,Java Game Development...
# 2

I would suggest, for symmetry/style reasons to start your client and server threads from the applet and put the logic of them away in the seperate threads, e.g.

Thread clientThread = new MyClientThread();

Thread serverThread = new MyServerThread();

clientThread.start();

serverThread.start();

...

> Thread secondThread = new MyThread();

> secondThread.start();

>

>

> ...

>

> class MyThread extends Thread

> {

>public void run()

>{

>for(;;)

>{

> // your second thread running here

>}

>}

> }

jpw35 at 2007-7-6 11:27:37 > top of Java-index,Other Topics,Java Game Development...