android - Best Collection for managing producer-consumer byte array -
i'm using bytebuffer producer offers array of bytes store. have thread looks through bytebuffer searching byte sequence (a start code) determine if have complete message or not. if find complete message, extract byte array , fire event various listeners. way producer sends me data, in chunks.
i have lot of gyrations make bytebuffer thread safe , doesn't seem elegant @ all.
is there better way this?
i suggest priorityblockingqueue. java.util.concurrent
package meaning, can safely accessed different threads. fifo implementation. put bytes inside collection , wait them in different thread.
Comments
Post a Comment