Metonymy is a figure of speech in which a thing or a concept is called not by its own name but by the name of something that is closely related to it. For example, we might see the following sentence in a newspaper: "The White House has decided to close the prison at Guantanamo Bay." We know that the physical White House did not make this decision but that the President of the United States did. Because the White House is so closely associated with the president, we sometimes use the words interchangeably.
Synecdoche, then, is a specific type of metonymy in which the name for a part of something is used in place of the name for the whole thing. For example, the common Navy phrase "All hands on deck." This phrase means that all people (not just their hands) should report to the deck of the ship. Another example might be "you have hungry mouths to feed." Obviously, you are feeding more than the mouths, you are feeding the entire person.