implmented parts of minithread.c