Former Formula 1 chief executive Bernie Ecclestone has criticized seven-time world champion Lewis Hamilton, describing him as "whining" and making a pointed remark about his potential retirement.