#ifndef _TEST_APP
#define _TEST_APP


#define OF_ADDON_USING_OFTHREAD
		
#include "ofMain.h"
#include "ofAddons.h"

//our simple thread class
class thread1 : public ofThread{

	public:
		//--------------------------
		thread1(){
			count = 0;
		}
				
		//--------------------------
		void threadedFunction(){
			while( isThreadRunning() != 0 ){
				if( lock() ){
					count++;
					if(count > 500000) count = 0;
					unlock();
				}
			}
		}

		//--------------------------
		void drawCount(){
			string str = "threaded count is ";		
			if( lock() ){
				str += ofToString(count);
				unlock();
			}else{
				str = "Can't Lock!";
			}						
			ofDrawBitmapString(str, 10, 16);
		}
	int count;
};



class testApp : public ofSimpleApp{
	
	public:
		
		void setup();
		void update();
		void draw();
		
		void keyPressed(int key);
		void keyReleased(int key);
		void mouseMoved(int x, int y );
		void mouseDragged(int x, int y, int button);
		void mousePressed(int x, int y, int button);
		void mouseReleased();
		
		thread1 T1;
		
		int count;
};

#endif	

