java - Multiple ports and threading -
i designing android software have listen n-amount of ports, lets 10. every 100ms want check out if ports have new udp-packet. after receiving packet, data inside should passed ui-thread.
my question should use 1 thread receive data different ports or should create own thread every port, each timed run @ 100ms interval? practice in these cases?
when port has data, deserialized object, used update data in views in ui-thread.
i'm quite new socket-programming , more advanced concurrent-programming have been hesitating time without finding answers web.
having thread per socket seems overkill , unless time de-serialize object excessive won't see benefit.
personally (and bas pointed out; there's not in it) start out simple , have single thread checking 10 ports round-robin , sleeping between checks. if start find thread taking time processing data , time between each port being checked high can add more threads pool @ point.
Comments
Post a Comment