This is mytherious.. :/
Code: Select all
#define thread_uninitalized 0
#define thread_running 1
#define thread_crashed 2
type thread_controller
state as uinteger
declare sub reboot(t_adress as any ptr,byref state as uinteger)
end type
sub thread_controller.reboot(t_adress as any ptr,byref state as uinteger)
PRINT "REBOOTING..";
if state = thread_crashed then
PRINT "EXECUTE..";
threadcreate t_adress
sleep 100
if state = thread_running then print "REBOOT SUCCESFULL" ELSE PRINT "SOMETHING IS WORONG."
else
print "NO REASON TO REBOOT"
end if
end sub
sub instable_thread
PRINT "INSTABLE THREAD IS RUNNING NOW"
static as integer threads
static as integer reboot_state
threads+=1
on error goto error_handler
dim as thread_controller ctrl
ctrl.state = thread_running
reboot_state = thread_running
do
if int(rnd*10000)=0 then error 10000
loop
exit sub
error_handler:
print "ERRORHANDLER STARTED!"
print "THREADS : ";THREADS
ctrl.state = thread_crashed
reboot_state = thread_crashed
threads-=1
PRINT "RESTARTING..";
ctrl.reboot @instable_thread,reboot_state
PRINT "END OF ERRORHANDLER!!"
end sub
instable_thread
sleep