There's no relationship drawn between your boost::thread t[]
and boost::thread_group threads;
.
So t[iterator].interrupt();
has no effect on the threads spawned by threads.create_thread(boost::bind(&InputThread)) ;
.
Instead do:
std::vector<boost::thread *> thread_ptrs;
// ...
thread_ptrs.push_back(threads.create_thread(boost::bind(&InputThread)));
// ...
thread_ptrs[iterator].interrupt();
Aside: the name "iterator" is often used for types and makes a poor value to iterate over. Use i
or some other idiomatic name for this value.