I am working on Thread Queue. My aim is ensure not overlap that more than one toast at same time. Example Call toasts in onCreate,onStart,onResume states.
Firsty i create a class for toast helper that has toast queue with activity context. That queue execute a thread until queue has no items but this code is not work. But i dont know toast how to do wait a thread for toast ? if i use Thread.Sleep(4000) then main UI freezes
 public static void CreateToast(final ToastSettings toastSettings) {
        _toastQueue.add(toastSettings);
        if (_toastQueue.size() == 1) {
            new Handler().post(new Runnable() {
                @Override
                public void run() {
                    while (_toastQueue.size() != 0) {
                        Toast.makeText(_toastQueue.get(0).getContext(), _toastQueue.get(0).getMessage(), _toastQueue.get(0).isLong() ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT).show();
                        _toastQueue.remove(_toastQueue.get(0));
                        //thread sleep 4sec ??
                    }
                }
            });
        }
    }
 
     
    