Can i use this code inside a service for calling a method with delay or `Handler()` should only be used inside a `UI` thread ?

What is the best way for calling a method with delay inside a `service`?

```
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
  @Override
  public void run() {
    //Do something after 10000ms
    socket.emit("CancelTravel");
  }
}, 10000);

```