Multiple Threads and their interaction

Hi guys, a complete n00b in game dev here. I just tried making a simple game using swing. I made the game loop (the one that iterates over pressed buttons) in a separate thread. But I have a serious problem, I really lack skills in multithread programming. In the end of the loop I used Thread.currentThread().wait(20) so the picture would have time to get repainted… but something tells me that it is not a good way at all. Could you guys tell me how to make it the right way or how to improve my knowledge in multithread programming?