
#import "Counter.h"
#import <threadkit/threadkit.h>

@implementation Counter

- awakeFromNib
{
	thread = [ [ TKThread alloc ] initFor: self
			perform: @selector ( startCounter ) ] ;
	return self ;
}

- startCounter
{
	while ( 1 )
	{
		counter = 0 ;
		while ( counter <= 100 )
		{
			[ TKThread yield ] ;
			[ NXApp threadLock ] ;
			[ target setIntValue: counter ] ;
			[ NXApp threadUnlock ] ;
			counter++ ;
		}
		sleep ( 2 ) ;
	}
}

- suspend: sender
{
	[ thread threadLock ] ;
	return self ;
}


- resume: sender
{
	[ thread threadUnlock ] ;
	return self ;
}

@end
