4
Задача
Java Core, ниво, урок
join: at the right time in the right place
The join method is very useful and is often used to terminate a thread. Think about where and on what object you need to call this method to have the result displayed
18
Задача
Java Core, ниво, урок
Horse racing
Programming is better than gambling... Still, horse races and other races perfectly illustrate multithreading! Figure out what the code does, and implement a method that counts the number of horses that have crossed the finish line. One more thing: you need to wait for the longshots to finish the race.
9
Задача
Java Core, ниво, урок
Promotion during political debates
Mr Chump is our candidate! And we'll help him a bit by making him give a speech, and then another, and then another during a political debate. We'll help him a little by making him talk until all the available time has been taken. Threads come to our rescue!
4
Задача
Java Core, ниво, урок
Justice
Justice is the name of an ancient Terrian deity that no one ever saw in the flesh. That said, Justice is sometimes encountered in man-made systems. We've got some mice here. For some reason, one of the mice, the alpha male, eats first while the others wait. Figure out why and remove this method call.
9
Задача
Java Core, ниво, урок
Arranging calls to join()
First, the cat gives birth to kittens. Then all the kittens climb out of the basket in random order. Finally, the cat brings them back into the basket. These events for one cat may be interspersed with events for another cat. Now implement this scenario with join().