A job is a fire-and-forget task. An operation that, once started, you will not be waiting on, unless, maybe, there's an exception. The most common way to create a job is to use the launch() coroutine builder, as shown:
fun main(args: Array<String>) = runBlocking {
val job = launch {
// Do background task here
}
}
However, you can also use the Job() factory function, like this:
fun main(args: Array<String>) = runBlocking {
val job = Job()
}
Job is an interface, and both launch() and Job() return the JobSupport implementation, which is the basis of many implementations of Job. Deferred—which we will see as we move ahead—is an interface that extends Job.