Use k_thread_foreach() API instead of iterating over the _kernel.threads list. Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>