I am designing a matching memory game, I am almost done with it and everything is working as it should be, however, when the user has opened two different cards the program won't pause(wait) few seconds so the user can see what the second card was. 
I have tried using a long for loop operation but encountered the same problem. I have tried Thread.sleep, TimeUnit.SECONDS.sleep, Task and Platform.runLater.

The program opens the card and closes it instantly THEN it waits for the specified duration, keeping in mind that I am calling pauseThread after open and before close functions.

I have tried the above suggestions but they are leading me no where and I can't seem to find where the problem is with my code or where should I place the pauseThread. Thanks in advance.

```
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.concurrent.TimeUnit;

import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.*;
import javafx.scene.control.*;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.*;
import javafx.stage.Stage;

public class MemoryMatchingGame extends Application{
    private static Card selectedCard=null;                  // This is to save a reference for the first card to use in comparison
    private static int numOfCorrectPairs = 0;       // Keeping track of how many cards the user got correct

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {

        String[] images = {"C:\\Users\\userName\\Desktop\\Project#4\\1.png",            // This is a string array to store images locations
                "C:\\Users\\userName\\Desktop\\Project#4\\2.png",
                "C:\\Users\\userName\\Desktop\\Project#4\\3.jpg",
                "C:\\Users\\userName\\Desktop\\Project#4\\4.jpg",
                "C:\\Users\\userName\\Desktop\\Project#4\\5.jpg",
                "C:\\Users\\userName\\Desktop\\Project#4\\6.png",
                "C:\\Users\\userName\\Desktop\\Project#4\\7.jpg",
                "C:\\Users\\userName\\Desktop\\Project#4\\8.jpg"};
        ArrayList<Card> listOfCards = new ArrayList<Card>();

        for(int i=0; i<images.length; i++) {                                            // This for loop will add each image twice to the array list
            listOfCards.add(new Card(images[i]));
            listOfCards.add(new Card(images[i]));
        }
        Collections.shuffle(listOfCards);                                               // Shuffling the deck of cards

        primaryStage.setTitle("Memory Matching Game");
        HBox hb = new HBox();

        VBox firstColoumn = new VBox();
            for(int i=0; i<4; i++) 
                firstColoumn.getChildren().add(listOfCards.get(i));
        VBox secondColoumn = new VBox();
            for(int i=4; i<8; i++) 
                secondColoumn.getChildren().add(listOfCards.get(i));
        VBox thirdColoumn = new VBox();
            for(int i=8; i<12; i++) 
                thirdColoumn.getChildren().add(listOfCards.get(i));
        VBox fourthColoumn = new VBox();
            for(int i=12; i<16; i++) 
                fourthColoumn.getChildren().add(listOfCards.get(i));

        hb.getChildren().addAll(firstColoumn, secondColoumn, thirdColoumn, fourthColoumn);

        Scene scene = new Scene(hb, 460, 450);
        primaryStage.setScene(scene);

        primaryStage.show();
    }

    private class Card extends Button {
        private String imageLocation;       // To store the destination of the image
        private Image img;                  // To store a reference of the image to be used when setting graphic on a button

        public Card(String imageLocation) throws FileNotFoundException {
            this.imageLocation = imageLocation;
            FileInputStream fis = new FileInputStream(imageLocation);
            img = new Image(fis);

            setPrefSize(150, 150);

            setOnMouseClicked(e -> {
                if(isCardOpen()==true)
                    return;             // To ensure no action is made once an image is already opened and the user clicked on it again

                if(selectedCard==null) {// This will test if the user has a card open already for comparison or not, if not it will store a reference to the card to use to compare once another card is opened
                    selectedCard = this;
                    open();
                }
                else {                  // If we enter this statement, this means the user has a card open already and we are ready to perform comparison

                    open();             // First action taken is to reveal the second card then perform comparison

                        if(this.isEqual(selectedCard)) {
                            numOfCorrectPairs++;
                            System.out.println("Got one");
                        }
                        else {
                            //Get program to pause here

                            Hold pauseThread = new Hold();
                            pauseThread.run();

                            System.out.println("After pausing");
                            this.close();
                            selectedCard.close();
                        }

                        selectedCard=null;      // This will nullify the variable so that we are able to perform comparison again for two other cards
                }                       // End of else statement

            });                         // End of actionHandler

            close();                    // This will ensure whenever a card is created it is set face-down
        }

        private void close() {
            setGraphic(null);
        }
        public void open() {
            setGraphic(new ImageView(img));
            System.out.println("Open");
        }

        private boolean isCardOpen() {
            return this.getGraphic()!=null;
        }

        private boolean isEqual(Card selectedCard) {
            return this.imageLocation.equals(selectedCard.imageLocation);
        }
    }

    private class Hold extends Thread{
        public void run() {
            try {
                TimeUnit.SECONDS.sleep(3);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }
}

```