Threads in a standalone application

I have a problem with a standalone threaded application. The system is
Linux 3.7.10-1.1-desktop, openSUSE 12.3 (Darthmouth) (x86_64) with
ROOT 5.34/21 (v5-34-21@v5-34-21, Sep 09 2014, 15:29:00 on linuxx8664gcc)

The application runs well, but if I do some interactions in the GUI (e.g. resize statistics panel) it crashes.

Here is the minimal example

#include <stdio.h>

//X11
//#include <X11/Xlib.h>

// ROOT
#include <TApplication.h>
#include <TThread.h>
#include <TCanvas.h>
#include <TH1S.h>

void *application(void *arg);

TThread* thread;
TCanvas* c;
TH1S*    hist;

int main(int argc, char** argv)
{
    //XInitThreads();
    TApplication theApp("App", &argc, argv);
    TThread::Lock();
    c = new TCanvas("c", "TEST", 600, 400);
    hist   = new TH1S("h","Hist",4,0,3);
    thread = new TThread("application",application,NULL);
    thread->Run();
    TThread::UnLock();
    theApp.Run();    
    return 0;
}

void *application(void *arg)
{
   printf("run in thread...\n");
   while(1)
   {
       TThread::Lock();
       hist->Fill((unsigned short)2);
       c->cd();
       hist->Draw("hists");
       c->Modified();
       //c->Update();
       TThread::UnLock();
       TThread::Sleep(1);
   }
}

This code was also tested on windows an it crashes too.

and here is the output…

How do I handle threads in a standalone application properly?