This will take a lot of hand coding to accomplish.
you would need to have a column in the message table to lark whether the message was read or not, on page load, lookup the ID of the user reading the message, and if it matches the ID of the person that started the thread, update that column value.