Im building a Reversi program and i need to delay the program for something like 0.5 second between each image switch (from black to white, in the Eat function), problem is that using Threads doesnt work, it messes up the variables and i get the wrong outcome. i need some wat to delay the program without using threads. Here is the func in case youll need it.
public void func1(int turn)
{
int i,k;
for(i=0;i<8;i++)
for(k=0;k<8;k++)
{
if(eat[i][k]==turn)
{
board[i][k]=turn;
if(turn==1)
squares[i][k].setIcon(new ImageIcon("blkimg.PNG"));
else
squares[i][k].setIcon(new ImageIcon("whtimg.PNG"));
}
}
}
Thanks alot.
You won't need extensive knowledge of threads to put the current one to sleep using Thread.sleep()
- I would recommend taking a look at http://docs.oracle.com/javase/tutorial/essential/concurrency/sleep.html