I wrote some code like this
class TestObject: public CCObject
{
//some code
}
class Thread:public CCObject
{
public :
~Thread()
{
if(obj)
{
obj->release();
}
}
void start(){/*some code to start the thread*/}
void run()
{
doSomeJob();
obj = new TestObject();
m_exit = true;
}
bool m_exit;
TestObject* obj;
}
//schedule func
void TestScene::update_test(ccTime t)
{
if(!m_thread)
{
m_thread = new Thread();
m_thread->start();
}
if(m_thread&&m_thread->m_exit)
{
m_thread->release();
//director to other scene
}
}
it crash when i build and run it under the android.
this code do some job like that:
I start a new thread use pthread and in this new thread I use it to login the game server and load the user data from the server, on the load scene schedule function i test if this job is done if done read this data and release the thread.
Can some one figure out the problem why the game crash. Thanks.