If your bluetooth stream can try at 10 milliseconds, you can use it directly. Otherwise, you will need a new thread operating at a frequency of 10 ms. Assuming the accuracy of the data transfer speed is not high enough, therefore, Thread.sleep () when sending the stream will be sufficient, and some cross-thread communication will be required - there are clearly defined templates for this task. Only one of them: http://javaprogramming.language-tutorial.com/2012/09/interthread-communication-java.html
Thus, in the general case, you have a data transmission thread with a sleeping value of 10 milliseconds, the bluetooth stream sends everything that has to this send stream, through the template above. The transmitted data is stored in the buffer of the same queue, and the sending stream receives them one by one with a sleep () between attempts to send.
source share