I am looking for an efficient way to calculate the traffic speed for my app. I have multiple concurrent threads downloading data over the network. I have a facade that collects how many bytes they have read via a call to facade.setCurrentData(int data)
Now, every second I grab the currentData field to calculate the speed for the particular second. so this will do the math to figure out the speed and then reset the currentData field to 0. Of course all this runs synchronized, along with the setCurrentData method, which leads me to believe this is not very efficient as the download threads need to wait to aquire lock before posting the total speed. Is there a more efficient way?
EDIT
Your only options are to: