Professional Documents
Culture Documents
Experiment 7 Program
Experiment 7 Program
Write a Java multi-threaded program to implement the tortoise and hare story. Make the hare sleep at the mid of the
way and let the tortoise win.
Source Code:
{
for(int a=1;a<11;a++)
{
}
try
{
}
catch(InterruptedException ie)
{
}
for(int b=11;b<21;b++)
{
{
for(int c=1;c<21;c++)
{
}
System.out.println("!!!!!!!!!!!!!!!!TORTOISE HAS WON THE RACE !!!!!!!!!!!!!!!!!!!!!"); // tortoise won the race
}
Output:
Text Books
T1: Herbert Schildt (2019), “Java The Complete Reference, Ed. 11, McGraw-Hill publishing company Ltd.
Reference Books
Research Papers
1.https://www.researchgate.net/publication/337482569_Threads_and_Multithreaded_in_java
2.https://www.researchgate.net/publication/
330278781_Analysis_of_Multithreading_in_Java_for_Symbolic_Computation_on_Multicore_Processors
3.https://www.academia.edu/Documents/in/Multi-threading