manasij7479 thanks for your reply... actually in 2nd semester of Computer Science we haven't yet studied about threads.. so I can't use threads as i don't know about them, & its looking quiet difficult to use threads. I want to know that can i run time function, ghost function & Pac-Man move function in one time,, because lets say in a function body, when i stops moving pacman the ghost & time function will also stop, so i want to know that is there any other way accept threads, which is easy to which i can use, your help will be greatly appreciated, Thanks once again

I want to know that can i run time function, ghost function & Pac-Man move function in one time,, because lets say in a function body, when i stops moving pacman the ghost & time function will also stop, so i want to know that is there any other way accept threads, which is easy to which i can use, your help will be greatly appreciated, Thanks once again

You'll need a game loop for that, which will run once per frame and update all the entities.

As it has been said already, there is no need to use threads.
Even though it might appear like the objects are all moving "at the same time", really they don't have to!
Regarding the ghost logic: give every ghost a direction of movement and change it:
- when the ghost hits a wall
- randomly with a small likelihood
- when the ghost is at a junction and it can get closer to Pacman by changing its direction

@TomasRiker i have figured out the frames thing & my pac man is moving good, firstly i am trying to make ghost which moves randomly, & my AI is not that good & it gets stuck most of the time, like games with bad AI, so can you give me something of little pseudo code type of GHOST AI. Thanks

You do not need any major path finding algorithms to implement pac-man. The original actually did not use path finding at all. All you need to do is a bump and grind type algorithm where if pacman is above the ghost the ghost constantly tries to move up - if it cant it will move up the first chance it gets. The same holds true for all other directions.