1. A controller for a machine tool used for thread cutting by means of lathe-turning machining on a work, comprising:a processor configured
to calculate an oscillation amplitude and an oscillation direction allowing shredding of chips occurring from the lathe-turning machining based on an infeed amount in a radial direction of the work and a shift amount in a circumferential direction of the work relative to a last machining path of a tool used for the lathe-turning machining on the work;
to calculate an oscillation command for causing the work and the tool to oscillate relative to each other based on the oscillation amplitude and the oscillation direction calculated by the oscillation condition calculation unit; and
to add a movement command for moving the work and the tool relative to each other for the lathe-turning machining on the work and the oscillation command.