question

Marcel Tricolici avatar image
Marcel Tricolici asked

is Whispersync API thread-safe?

Hi guys, I have some simple questions.. I can't find this in documentation: 1. Can be Whispersync API called from any thread or only from the main ? 2. Is Whispersync API thread-safe or we should implement our own synchronization?
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Marcel Tricolici avatar image
Marcel Tricolici answered
if Whispersync use AsyncTask then it is limited to main thread only :(... as it's not recommended to create AsyncTasks from other threads (we had some issues with it on some devices)
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Bipin@Amazon avatar image
Bipin@Amazon answered
Yes, This is thread safe. I created this below method public void submitscore(int score) { SyncableNumberList syncableNumberList = gameDataMap.getLatestNumberList("SyncableNumberList"); syncableNumberList.setMaxSize(20); syncableNumberList.add(score); } i have multiple thread submitting score in a for loop new Thread(new Runnable() { public void run() { submitscore(); } }).start(); Still able to pull the score out from "SyncableNumberList" . This is new thread and not on main thread. what do you mean by issues in some device? Can you help us to replicate your scenario.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Marcel Tricolici avatar image
Marcel Tricolici answered
Thanks.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.