Skip to content

Instantly share code, notes, and snippets.

@vishalratna-microsoft
Created September 9, 2022 16:59
Show Gist options
  • Save vishalratna-microsoft/4a8817e8cdf31816813ed47cc47c2f48 to your computer and use it in GitHub Desktop.
Save vishalratna-microsoft/4a8817e8cdf31816813ed47cc47c2f48 to your computer and use it in GitHub Desktop.
Submission of work is easy if work is submitted alone.
package com.tutorials.vishal;
import com.tutorials.vishal.hierarchy.BaseWork;
import com.tutorials.vishal.hierarchy.RxWork;
import com.tutorials.vishal.hierarchy.Scheduler;
public class DemoClass {
void driver() {
BaseWork work = new BaseWork();
RxWork rxWork = new RxWork();
// We are able to submit all types of work. Yay!
startJob(work); // Valid!
startJob(rxWork); // Valid, polymorphism magic.
}
void startJob(BaseWork incomingWork) {
// validate the work and submit.
Scheduler.submit(incomingWork);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment