Is there something you can do to unblock a blockked function?

For example:
Thread1
allocate dynamic memory
blocking function();
free dynamic memory
End

Thread2
unblock Thread1
End

Is it possible for Thread2 to unblock Thread1 and still have the dynamic memory freed?

Thanks,
Joe