Novice User
Novice User

Reputation: 3824

Generically pass different parameters to the method

Lets assume I've two variables ;

Future<MyCustomObj1> mytask1 = <something 1>
Future<MyCustomObj2> mytask2 = <something 2 >

I want to cancel both tasks in case of any InterruptException,

so something like

mytask1.cancel(true);
mytask2.cancel(true);

instead of repeating it everywhere, I want to create a generic method which can take the Future task as argument and just call cancel.

public void cancelTasks(<fill here>) {
   <fill here>.cancel(true);
}

What should I substitute for <fill here> ?

Upvotes: 0

Views: 38

Answers (1)

Joe C
Joe C

Reputation: 15704

Future<?> future

It means "a Future of some unknown type".

Upvotes: 1

Related Questions