Hi,
I have this program that reads about 2MB of data per second from a socket and then parses it. The data consists of messages which look like this: f72,0f4o385000y390000v887f12,86100. So, I'm looking byte by byte through the received buffer (byte[1024 * 32]) and reading my data into the objects. So to get a number out of this I use the following code:
While program runs it takes up pretty much 100% of the processor yet it seems to be able to keep up with the incoming data (so far at least).
My question is, maybe there is a better way to do that? Also, why do loops in java take up 100% CPU?
Any input appreciated
I have this program that reads about 2MB of data per second from a socket and then parses it. The data consists of messages which look like this: f72,0f4o385000y390000v887f12,86100. So, I'm looking byte by byte through the received buffer (byte[1024 * 32]) and reading my data into the objects. So to get a number out of this I use the following code:
While program runs it takes up pretty much 100% of the processor yet it seems to be able to keep up with the incoming data (so far at least).
My question is, maybe there is a better way to do that? Also, why do loops in java take up 100% CPU?
Any input appreciated