3f4 Subj : Re: thread log file To : comp.programming.threads From : azb123 Date : Tue Aug 09 2005 01:31 am Jason Jesso wrote: > I have a system with multiple threads. Each thread outputs to a log > file when it starts: > > "StartThread-N" where N is the Thread id > > When each thread exists it outputs > > "StopThread-N" > > What's the most efficient way of reporting which thread have not > stopped, assuming very large log files? Hi Jason, how about a little bit of awk (not tested): /^StartThread/ { sub(/StartThread-/,"",$1); if (status[$1] == "started") printf("Nesting error for thread %s\n",$1); else status[$1] = "started"; } /^StopThread/ { sub(/StopThread-/,"",$1); if (status[$1] == "stopped") printf("Nesting error for thread %s\n",$1); else status[$1] = "stopped"; } END { for (thread in status) if (status[thread] == "started") printf("Thread %s has not yet stopped.\n",thread); } . 0