multithreading - JAVA - MultiThread Server - Lag Between Receive And Send -


my multithread udp server launches 100 threads @ maximum. in each thread connects external devices , receives each data stream. after receiving have temporal window in need send external device acknowledge.

receive bit inside run().

byte[] receivedata = new byte[2000]; datagrampacket receivepacket = new datagrampacket(receivedata, receivedata.length); serversocket.receive(receivepacket); 

send bit inside run() after receive.

datagrampacket reply = new datagrampacket(senddata,senddata.length,receivepacket.getaddress(),receivepacket.getport(); serversocket.send(reply); 

when running wireshark analyse network traffic notice after server receives data stream doesn't send ack package right after, takes several seconds , several other communications other devices until acknowledge package sent device causing timeout on device side.

in multithread environment server waits threads finish before sending packets?

because packet goes out of server waits packets come input server.

the socket has same queue reading , writing?

thanks in advance i'm going nuts! :)

in multithread environment server waits threads finish before sending packets?

no.

the socket has same queue reading , writing?

no.

you must have synchronization between threads you've overlooked. in receivepacket itself.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -