diff --git a/04_day.pptx b/04_day.pptx index 4cf5dc4..2788fad 100644 Binary files a/04_day.pptx and b/04_day.pptx differ diff --git a/04_day/thread/Thread.cpp b/04_day/thread/Thread.cpp index 498d09c..e701fd5 100644 --- a/04_day/thread/Thread.cpp +++ b/04_day/thread/Thread.cpp @@ -1,3 +1,40 @@ +#if 0 +#include +#include +#include + +using namespace android; +//-------------------------------------------------------- +class AAA : public RefBase +{ + int ratio=0; + public: + AAA() + { + printf("AAA::AAA()\n"); + } + void onFirstRef() + { + ratio = 100; + printf("AAA::onFirstRef()\n"); + } + + bool foo(void) + { + printf("AAA::foo()\n"); + return false; + } +}; +int main() +{ + sp pa = new AAA; + //AAA *pa = new AAA; + pa->foo(); + //delete pa; + return 0; +} +#endif + #if 1 #include #include @@ -9,11 +46,26 @@ class MyThread : public Thread { int volume; public: + MyThread() + { + printf("MyThread::MyThread()\n"); + } + void onFirstRef() + { + printf("MyThread::onFirstRef()\n"); + } + status_t readyToRun() + { + printf("MyThread::readyToRun()\n"); + return NO_ERROR; + } + bool threadLoop(void) { volume=100; printf("MyThread::threadLoop(), volume=%d\n", volume); - return false; + sleep(1); + return true; } }; int main()