0

I am trying to find a way to utilize ExecutorService.submit(Runnable r, T result) method , but cannot find/Imagine any. Can anyone explain how this method is best utilised with a code example.

Thanks in Advance.

Roshan
  • 667
  • 1
  • 5
  • 15
  • Have you tried anything? – daniu Sep 12 '17 at 15:25
  • Take a look at [this question](https://stackoverflow.com/questions/3929342/choose-between-executorservices-submit-and-executorservices-execute). – Emanuele Giona Sep 12 '17 at 15:26
  • Yes, tried ExecutorService.submit(Runnable r) and ExecutorService.submit(Callable c) , both which i have understood , but not ExecutorService.submit(Runnable r, T result) method , any pointer will be helpful – Roshan Sep 12 '17 at 15:27
  • @EmanueleGiona , i have already went over the question thanks , but i cannot imagine any ways to utilise ExecutorService.submit(Runnable r, T result) method. – Roshan Sep 12 '17 at 15:29
  • Glue code for when you have a `Runnable` and need a `Future`, and you can't change those. – Kayaman Sep 12 '17 at 15:38

1 Answers1

1

You are perhaps wondering what the point of this method is? If so, you're not the only one :)

And if you are wondering am I missing something here? ... you're probably not. I've never encountered a use case for that method or, at least, a use case which was compelling and could not be achieved in any other way.

glytching
  • 44,936
  • 9
  • 114
  • 120
  • You're assuming that other ways are available for use. If you're working with a constrained environment trying to glue two pieces of code together, it might be useful to essentially convert a `Runnable` to a `Callable`. – Kayaman Sep 12 '17 at 15:31
  • Indeed, I'm not claiming that there is no possible need for it **ever**. I'm just saying that I have never found a use for it and there are pre existing questions on SO which strongly suggest that this experience is not unique to me :) – glytching Sep 12 '17 at 15:35
  • @glitch Thanks for lending a hand – Roshan Sep 12 '17 at 15:43