Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Laboratory 3 - Documentation

Problem 1
After I created the thread an tried to use the start method twice I got the exception
“IllegalThreadStateException” because you can’t start a thread twice.

Problem 2
Instead of using start() here we run() and this time no exception is thrown, because the thread finish all
the instruction in the run function and the runs again, after that the program is completed.

Problem 3
After I implemented the problem from the course and checked if all worked fine we could notice the
multi threading feature the numbers were showing in the GUI and then a tick was heard at every
decrement of the number and a beep every time the number passed 0.

Problem 4
After implementing both ways for resolving the prime numbers exercise, we can see that both methods
are faster than a traditional algorithm to find prime numbers. In my opinion the second implementation
is faster because after the first step the interval is smaller (has less number in him).

Problem 5
The horse track problem was very interesting, we could see how the output differs on almost every run
of the program, and the winners at the end of the round were also different. (See in the screenshot
bellow).
Problem 6
After having a look at the Thread class in the Java’s web page I saw some interesting methods like:

 getState() – return the state of the thread


 setPriority() – changes the priority of the thread
 notify() – wakes up a thread
 notifyAll() – wakes up all the threads

You might also like