Workers in programs

Report a typo

Take a look at a class that extends Thread:

class Worker(val line: String) : Thread() {
    override fun run() {
        println(line)
    }
}

There are two applications that use this class. Select all correct statements about them.

The first application:

class Application1 {
    fun startWork() {
        val t1 = Worker("Hello from t1")
        val t2 = Worker("Hello from t2")
        val t3 = Worker("Hello from t3")
        t1.start()
        t2.start()
        t3.start()

        t1.join()
        t2.join()
        t3.join()
    }
}

The second application:

class Application2 {
    fun startWork() {
        val t1 = Worker("Hello from t1")
        val t2 = Worker("Hello from t2")
        val t3 = Worker("Hello from t3")

        t1.start()
        t1.join()

        t2.start()
        t2.join()
        
        t3.start()
        t3.join()
    }
}
Select one or more options from the list
___

Create a free account to access the full topic