I am fairly new to java, and am starting to get into using different threads in order to use wait()
or sleep()
on one part of my code and have the others still run.
For this project, I am using JFrame
with the javax.swing.*
and java.awt.*
imports. What I am trying to do is have one of the threads (in my code it is the main, starting thread) allow the player to choose a space on the tic tac toe board, and when they click it, it will change icons, and then the AI will wait for 1 second before playing back from the second thread that I created.
Unfortunately, whenever I call ait.sleep(1000)
(ait
is my thread name) both threads wait for 1 second before finishing their execution. Can anyone tell me why sleeping one thread is stopping my whole execution?
ait.sleep(1000)
from inside theait
thread or from some other thread? – Each