I'm developing an android application which need to open up to 20 sockets (in parallel), and get an update from each one of them every 4 seconds (and update the UI respectively).
This is what I tried so far:
- Creating a TimerTask for each socket connection and use a handler and messages to post the updates to the UI thread. Problems with this solution: after creating about 15 TimerTasks (each one is on a different thread), the UI of my application (really simple) starts to leg. Second problem is that the updates from each socket is not even remotely synced (one updates each 4 seconds and the other one each 20 seconds for example).
- Creating one thread that deals all the communication using async socket channels and selector. Problems with this solution: Java doesn't have built in support for SSL (rather they just supplied an SSL engine, instead of an SSLChannelSocket), and I need SSL sockets.
Any Suggestions/other solutions?