Heating and activity of the solar corona: 2. Kink instability in a flux tube