Application error when finish thread

Why I have a error when finish the thread?
Can you check my code here:
Download here

What kind of error to you get?
And on which line of your code? Post that piece of source code.

Note that we gladly help, but you must do more than just throw code at us and ask us to fix it for you.

This is the error:

Process:               fornext.debug [1115]
Path:                  /Users/USER/*/fornext.debug.app/Contents/MacOS/fornext.debug
Identifier:            it.pesarosystem.fornext
Version:               ??? (1.0.0.0.0)
Code Type:             X86 (Native)
Parent Process:        ??? [1]
Responsible:           fornext.debug [1115]
User ID:               501

Date/Time:             2017-11-19 12:03:39.479 +0100
OS Version:            Mac OS X 10.12.5 (16F73)
Report Version:        12
Anonymous UUID:        8910C8B6-3CF9-0413-8EB9-F363E81AAD11


Time Awake Since Boot: 2300 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x000000000000000c
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Segmentation fault: 11
Termination Reason:    Namespace SIGNAL, Code 0xb
Terminating Process:   exc handler [0]

VM Regions Near 0xc:
--> 
    __TEXT                 0000000000001000-0000000000114000 [ 1100K] r-x/rwx SM=COW  /Users/USER/*/fornext.debug.app/Contents/MacOS/fornext.debug

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   com.apple.WebCore             	0x9998bde9 WebCore::TimerBase::updateHeapIfNeeded(double) + 409
1   com.apple.WebCore             	0x999893d1 WebCore::TimerBase::setNextFireTime(double) + 241
2   com.apple.WebCore             	0x999892d4 WebCore::TimerBase::start(double, double) + 52
3   com.apple.WebCore             	0x9a68e507 WebCore::ProgressTracker::progressStarted(WebCore::Frame&) + 151
4   com.apple.WebCore             	0x999cff8b WebCore::FrameLoader::prepareForLoadStart() + 203
5   com.apple.WebCore             	0x99b59830 WebCore::FrameLoader::continueLoadAfterWillSubmitForm() + 48
6   com.apple.WebCore             	0x99f1ce6a WebCore::FrameLoader::continueLoadAfterNavigationPolicy(WebCore::ResourceRequest const&, WTF::PassRefPtr<WebCore::FormState>, bool, WebCore::AllowNavigationToInvalidURL) + 1322
7   com.apple.WebCore             	0x99f215d3 std::__1::__function::__func<WebCore::FrameLoader::loadWithDocumentLoader(WebCore::DocumentLoader*, WebCore::FrameLoadType, WTF::PassRefPtr<WebCore::FormState>, WebCore::AllowNavigationToInvalidURL)::$_4, std::__1::allocator<WebCore::FrameLoader::loadWithDocumentLoader(WebCore::DocumentLoader*, WebCore::FrameLoadType, WTF::PassRefPtr<WebCore::FormState>, WebCore::AllowNavigationToInvalidURL)::$_4>, void (WebCore::ResourceRequest const&, WTF::PassRefPtr<WebCore::FormState>, bool)>::operator()(WebCore::ResourceRequest const&, WTF::PassRefPtr<WebCore::FormState>&&, bool&&) + 67
8   com.apple.WebCore             	0x999cef75 WebCore::PolicyCallback::call(bool) + 69
9   com.apple.WebCore             	0x999cef02 WebCore::PolicyChecker::continueAfterNavigationPolicy(WebCore::PolicyAction) + 786
10  com.apple.WebCore             	0x9a68545d std::__1::__function::__func<WebCore::PolicyChecker::checkNavigationPolicy(WebCore::ResourceRequest const&, bool, WebCore::DocumentLoader*, WTF::PassRefPtr<WebCore::FormState>, std::__1::function<void (WebCore::ResourceRequest const&, WTF::PassRefPtr<WebCore::FormState>, bool)>)::$_1, std::__1::allocator<WebCore::PolicyChecker::checkNavigationPolicy(WebCore::ResourceRequest const&, bool, WebCore::DocumentLoader*, WTF::PassRefPtr<WebCore::FormState>, std::__1::function<void (WebCore::ResourceRequest const&, WTF::PassRefPtr<WebCore::FormState>, bool)>)::$_1>, void (WebCore::PolicyAction)>::operator()(WebCore::PolicyAction&&) + 29
11  com.apple.WebKitLegacy        	0x9acaccf2 -[WebFramePolicyListener receivedPolicyDecision:] + 178
12  com.apple.WebKitLegacy        	0x9acacc39 -[WebFramePolicyListener use] + 41
13  HTMLViewerCocoa.dylib         	0x00211c64 0x20f000 + 11364
14  com.apple.CoreFoundation      	0x9425eaed __invoking___ + 29
15  com.apple.CoreFoundation      	0x9425ea2d -[NSInvocation invoke] + 317
16  com.apple.CoreFoundation      	0x9427859a -[NSInvocation invokeWithTarget:] + 74
17  com.apple.WebKitLegacy        	0x9acacbb7 -[_WebSafeForwarder forwardInvocation:] + 263
18  com.apple.CoreFoundation      	0x9425d331 ___forwarding___ + 465
19  com.apple.CoreFoundation      	0x9425d13e _CF_forwarding_prep_0 + 14
20  com.apple.WebKitLegacy        	0x9ad5d6c9 WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(WebCore::NavigationAction const&, WebCore::ResourceRequest const&, WTF::PassRefPtr<WebCore::FormState>, std::__1::function<void (WebCore::PolicyAction)>) + 281
21  com.apple.WebCore             	0x9a684c8a WebCore::PolicyChecker::checkNavigationPolicy(WebCore::ResourceRequest const&, bool, WebCore::DocumentLoader*, WTF::PassRefPtr<WebCore::FormState>, std::__1::function<void (WebCore::ResourceRequest const&, WTF::PassRefPtr<WebCore::FormState>, bool)>) + 2138
22  com.apple.WebCore             	0x99f1c785 WebCore::FrameLoader::loadWithDocumentLoader(WebCore::DocumentLoader*, WebCore::FrameLoadType, WTF::PassRefPtr<WebCore::FormState>, WebCore::AllowNavigationToInvalidURL) + 2309
23  com.apple.WebCore             	0x99f1b707 WebCore::FrameLoader::loadWithNavigationAction(WebCore::ResourceRequest const&, WebCore::NavigationAction const&, WebCore::LockHistory, WebCore::FrameLoadType, WTF::PassRefPtr<WebCore::FormState>, WebCore::AllowNavigationToInvalidURL) + 647
24  com.apple.WebCore             	0x99f1a25d WebCore::FrameLoader::loadURL(WebCore::FrameLoadRequest const&, WTF::String const&, WebCore::FrameLoadType, WebCore::Event*, WTF::PassRefPtr<WebCore::FormState>) + 1981
25  com.apple.WebCore             	0x99f18aff WebCore::FrameLoader::loadURLIntoChildFrame(WebCore::URL const&, WTF::String const&, WebCore::Frame*) + 927
26  com.apple.WebKitLegacy        	0x9ad5e286 WebFrameLoaderClient::createFrame(WebCore::URL const&, WTF::String const&, WebCore::HTMLFrameOwnerElement*, WTF::String const&, bool, int, int) + 502
27  com.apple.WebCore             	0x9a9362d3 WebCore::SubframeLoader::loadSubframe(WebCore::HTMLFrameOwnerElement&, WebCore::URL const&, WTF::String const&, WTF::String const&) + 291
28  com.apple.WebCore             	0x9a9352a1 WebCore::SubframeLoader::loadOrRedirectSubframe(WebCore::HTMLFrameOwnerElement&, WebCore::URL const&, WTF::AtomicString const&, WebCore::LockHistory, WebCore::LockBackForwardList) + 305
29  com.apple.WebCore             	0x9a9350bf WebCore::SubframeLoader::requestFrame(WebCore::HTMLFrameOwnerElement&, WTF::String const&, WTF::AtomicString const&, WebCore::LockHistory, WebCore::LockBackForwardList) + 911
30  com.apple.WebCore             	0x99fb4ef3 WebCore::HTMLFrameElementBase::openURL(WebCore::LockHistory, WebCore::LockBackForwardList) + 275
31  com.apple.WebCore             	0x99a64960 WebCore::HTMLFrameElementBase::setNameAndOpenURL() + 384
32  com.apple.WebCore             	0x99cb06ad WebCore::ContainerNode::notifyChildInserted(WebCore::Node&, WebCore::ContainerNode::ChildChangeSource) + 301
33  com.apple.WebCore             	0x99cb01e3 WebCore::ContainerNode::updateTreeAfterInsertion(WebCore::Node&) + 35
34  com.apple.WebCore             	0x99caff92 WebCore::ContainerNode::appendChildWithoutPreInsertionValidityCheck(WebCore::Node&) + 338
35  com.apple.WebCore             	0x99cb127d WebCore::ContainerNode::appendChild(WebCore::Node&) + 93
36  com.apple.WebCore             	0x9a62ac39 WebCore::Node::appendChild(WebCore::Node&) + 57
37  com.apple.WebCore             	0x9a3824bd WebCore::JSNode::appendChild(JSC::ExecState&) + 109
38  com.apple.WebCore             	0x99a28bec WebCore::jsNodePrototypeFunctionAppendChild(JSC::ExecState*) + 92
39  ???                           	0x0b0eeabd 0 + 185526973
40  com.apple.JavaScriptCore      	0x96817ebf llint_entry + 19171
41  com.apple.JavaScriptCore      	0x96817ebf llint_entry + 19171
42  com.apple.JavaScriptCore      	0x96817ebf llint_entry + 19171
43  com.apple.JavaScriptCore      	0x968181db llint_entry + 19967
44  com.apple.JavaScriptCore      	0x968181db llint_entry + 19967

That is not from the app you put up for download in your original post.

Sorry:

Process:               Thread.debug [1560]
Path:                  /Users/USER/*/Thread.debug.app/Contents/MacOS/Thread.debug
Identifier:            it.pesarosystem.thread
Version:               ??? (1.0.0.0.0)
Code Type:             X86 (Native)
Parent Process:        ??? [1]
Responsible:           Thread.debug [1560]
User ID:               501

Date/Time:             2017-11-19 12:59:10.275 +0100
OS Version:            Mac OS X 10.12.5 (16F73)
Report Version:        12
Anonymous UUID:        8910C8B6-3CF9-0413-8EB9-F363E81AAD11


Time Awake Since Boot: 5600 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000008
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Segmentation fault: 11
Termination Reason:    Namespace SIGNAL, Code 0xb
Terminating Process:   exc handler [0]

VM Regions Near 0x8:
--> 
    __TEXT                 0000000000001000-0000000000110000 [ 1084K] r-x/rwx SM=COW  /Users/USER/*/Thread.debug.app/Contents/MacOS/Thread.debug

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   com.apple.WebCore             	0x9998bde9 WebCore::TimerBase::updateHeapIfNeeded(double) + 409
1   com.apple.WebCore             	0x999893d1 WebCore::TimerBase::setNextFireTime(double) + 241
2   com.apple.WebCore             	0x999892d4 WebCore::TimerBase::start(double, double) + 52
3   com.apple.WebCore             	0x9a68e507 WebCore::ProgressTracker::progressStarted(WebCore::Frame&) + 151
4   com.apple.WebCore             	0x999cff8b WebCore::FrameLoader::prepareForLoadStart() + 203
5   com.apple.WebCore             	0x99b59830 WebCore::FrameLoader::continueLoadAfterWillSubmitForm() + 48
6   com.apple.WebCore             	0x99f1ce6a WebCore::FrameLoader::continueLoadAfterNavigationPolicy(WebCore::ResourceRequest const&, WTF::PassRefPtr<WebCore::FormState>, bool, WebCore::AllowNavigationToInvalidURL) + 1322
7   com.apple.WebCore             	0x99f215d3 std::__1::__function::__func<WebCore::FrameLoader::loadWithDocumentLoader(WebCore::DocumentLoader*, WebCore::FrameLoadType, WTF::PassRefPtr<WebCore::FormState>, WebCore::AllowNavigationToInvalidURL)::$_4, std::__1::allocator<WebCore::FrameLoader::loadWithDocumentLoader(WebCore::DocumentLoader*, WebCore::FrameLoadType, WTF::PassRefPtr<WebCore::FormState>, WebCore::AllowNavigationToInvalidURL)::$_4>, void (WebCore::ResourceRequest const&, WTF::PassRefPtr<WebCore::FormState>, bool)>::operator()(WebCore::ResourceRequest const&, WTF::PassRefPtr<WebCore::FormState>&&, bool&&) + 67
8   com.apple.WebCore             	0x999cef75 WebCore::PolicyCallback::call(bool) + 69
9   com.apple.WebCore             	0x999cef02 WebCore::PolicyChecker::continueAfterNavigationPolicy(WebCore::PolicyAction) + 786
10  com.apple.WebCore             	0x9a68545d std::__1::__function::__func<WebCore::PolicyChecker::checkNavigationPolicy(WebCore::ResourceRequest const&, bool, WebCore::DocumentLoader*, WTF::PassRefPtr<WebCore::FormState>, std::__1::function<void (WebCore::ResourceRequest const&, WTF::PassRefPtr<WebCore::FormState>, bool)>)::$_1, std::__1::allocator<WebCore::PolicyChecker::checkNavigationPolicy(WebCore::ResourceRequest const&, bool, WebCore::DocumentLoader*, WTF::PassRefPtr<WebCore::FormState>, std::__1::function<void (WebCore::ResourceRequest const&, WTF::PassRefPtr<WebCore::FormState>, bool)>)::$_1>, void (WebCore::PolicyAction)>::operator()(WebCore::PolicyAction&&) + 29
11  com.apple.WebKitLegacy        	0x9acaccf2 -[WebFramePolicyListener receivedPolicyDecision:] + 178
12  com.apple.WebKitLegacy        	0x9acacc39 -[WebFramePolicyListener use] + 41
13  HTMLViewerCocoa.dylib         	0x014b0c64 0x14ae000 + 11364
14  com.apple.CoreFoundation      	0x9425eaed __invoking___ + 29
15  com.apple.CoreFoundation      	0x9425ea2d -[NSInvocation invoke] + 317
16  com.apple.CoreFoundation      	0x9427859a -[NSInvocation invokeWithTarget:] + 74
17  com.apple.WebKitLegacy        	0x9acacbb7 -[_WebSafeForwarder forwardInvocation:] + 263
18  com.apple.CoreFoundation      	0x9425d331 ___forwarding___ + 465
19  com.apple.CoreFoundation      	0x9425d13e _CF_forwarding_prep_0 + 14
20  com.apple.WebKitLegacy        	0x9ad5d6c9 WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(WebCore::NavigationAction const&, WebCore::ResourceRequest const&, WTF::PassRefPtr<WebCore::FormState>, std::__1::function<void (WebCore::PolicyAction)>) + 281
21  com.apple.WebCore             	0x9a684c8a WebCore::PolicyChecker::checkNavigationPolicy(WebCore::ResourceRequest const&, bool, WebCore::DocumentLoader*, WTF::PassRefPtr<WebCore::FormState>, std::__1::function<void (WebCore::ResourceRequest const&, WTF::PassRefPtr<WebCore::FormState>, bool)>) + 2138
22  com.apple.WebCore             	0x99f1c785 WebCore::FrameLoader::loadWithDocumentLoader(WebCore::DocumentLoader*, WebCore::FrameLoadType, WTF::PassRefPtr<WebCore::FormState>, WebCore::AllowNavigationToInvalidURL) + 2309
23  com.apple.WebCore             	0x99f1b707 WebCore::FrameLoader::loadWithNavigationAction(WebCore::ResourceRequest const&, WebCore::NavigationAction const&, WebCore::LockHistory, WebCore::FrameLoadType, WTF::PassRefPtr<WebCore::FormState>, WebCore::AllowNavigationToInvalidURL) + 647
24  com.apple.WebCore             	0x99f1a25d WebCore::FrameLoader::loadURL(WebCore::FrameLoadRequest const&, WTF::String const&, WebCore::FrameLoadType, WebCore::Event*, WTF::PassRefPtr<WebCore::FormState>) + 1981
25  com.apple.WebCore             	0x99f18aff WebCore::FrameLoader::loadURLIntoChildFrame(WebCore::URL const&, WTF::String const&, WebCore::Frame*) + 927
26  com.apple.WebKitLegacy        	0x9ad5e286 WebFrameLoaderClient::createFrame(WebCore::URL const&, WTF::String const&, WebCore::HTMLFrameOwnerElement*, WTF::String const&, bool, int, int) + 502
27  com.apple.WebCore             	0x9a9362d3 WebCore::SubframeLoader::loadSubframe(WebCore::HTMLFrameOwnerElement&, WebCore::URL const&, WTF::String const&, WTF::String const&) + 291
28  com.apple.WebCore             	0x9a9352a1 WebCore::SubframeLoader::loadOrRedirectSubframe(WebCore::HTMLFrameOwnerElement&, WebCore::URL const&, WTF::AtomicString const&, WebCore::LockHistory, WebCore::LockBackForwardList) + 305
29  com.apple.WebCore             	0x9a935aa5 WebCore::SubframeLoader::requestObject(WebCore::HTMLPlugInImageElement&, WTF::String const&, WTF::AtomicString const&, WTF::String const&, WTF::Vector<WTF::String, 0ul, WTF::CrashOnOverflow, 16ul> const&, WTF::Vector<WTF::String, 0ul, WTF::CrashOnOverflow, 16ul> const&) + 693
30  com.apple.WebCore             	0x99fe9554 WebCore::HTMLPlugInImageElement::requestObject(WTF::String const&, WTF::String const&, WTF::Vector<WTF::String, 0ul, WTF::CrashOnOverflow, 16ul> const&, WTF::Vector<WTF::String, 0ul, WTF::CrashOnOverflow, 16ul> const&) + 436
31  com.apple.WebCore             	0x99fdffc3 WebCore::HTMLObjectElement::updateWidget(WebCore::CreatePlugins) + 323
32  com.apple.WebCore             	0x99a911a1 WebCore::HTMLPlugInImageElement::updateWidgetIfNecessary() + 177
33  com.apple.WebCore             	0x99fe9754 WTF::Function<void ()>::CallableWrapper<WebCore::HTMLPlugInImageElement::didAttachRenderers()::$_0>::call() + 20
34  com.apple.WebCore             	0x9a933735 WebCore::Style::PostResolutionCallbackDisabler::~PostResolutionCallbackDisabler() + 85
35  com.apple.WebCore             	0x9a93381b WebCore::Style::PostResolutionCallbackDisabler::~PostResolutionCallbackDisabler() + 11
36  com.apple.WebCore             	0x99df04fe WebCore::Document::recalcStyle(WebCore::Style::Change) + 1134
37  com.apple.WebCore             	0x999b65e4 WebCore::Document::updateStyleIfNeeded() + 132
38  com.apple.WebCore             	0x99a207ea WebCore::Document::updateLayout() + 122
39  com.apple.WebCore             	0x99df07c4 WebCore::Document::updateLayoutIgnorePendingStylesheets(WebCore::Document::RunPostLayoutTasks) + 308
40  com.apple.WebCore             	0x99fdee8f WebCore::HTMLObjectElement::renderWidgetLoadingPlugin() const + 31
41  com.apple.WebCore             	0x99fe69f1 WebCore::HTMLPlugInElement::pluginWidget(WebCore::HTMLPlugInElement::PluginLoadingPolicy) const + 33
42  com.apple.WebCore             	0x99a906aa WebCore::pluginScriptObject(JSC::ExecState*, WebCore::JSHTMLElement*) + 74
43  com.apple.WebCore             	0x9a3a5ac1 WebCore::pluginElementCustomGetOwnPropertySlot(JSC::ExecState*, JSC::PropertyName, JSC::PropertySlot&, WebCore::JSHTMLElement*) + 33
44  com.apple.WebCore             	0x99a90653 WebCore::JSHTMLObjectElement::getOwnPropertySlotDelegate(JSC::ExecState*, JSC::PropertyName, JSC::PropertySlot&) + 115
45  com.apple.WebCore             	0x9a2ffb5f WebCore::JSHTMLObjectElement::getOwnPropertySlot(JSC::JSObject*, JSC::ExecState*, JSC::PropertyName, JSC::PropertySlot&) + 47
46  com.apple.JavaScriptCore      	0x963bad37 llint_slow_path_get_by_id + 2199
47  com.apple.JavaScriptCore      	0x968155b3 llint_entry + 8663
48  com.apple.JavaScriptCore      	0x96817e6c llint_entry + 19088
49  com.apple.JavaScriptCore      	0x968181db llint_entry + 19967
50  com.apple.JavaScriptCore      	0x96817ebf llint_entry + 19171
51  com.apple.JavaScriptCore      	0x96817ebf llint_entry + 19171
52  com.apple.JavaScriptCore      	0x96817ebf llint_entry + 19171
53  com.apple.JavaScriptCore      	0x96817ebf llint_entry + 19171
54  com.apple.JavaScriptCore      	0x96817e...

But don’t you get the error when click on button “Start”?

How did you make the crash? This gives a ThreadAccessingUIException on

WebDett.LoadURL (c.sUrl)

Please see the documentation on Threads to learn about ThreadAccessingUIException.
http://documentation.xojo.com/index.php/Thread

[quote=360379:@Gabriele Marchionni]Sorry:

[...] Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 com.apple.WebCore 0x9998bde9 WebCore::TimerBase::updateHeapIfNeeded(double) + 409 [...] 54 com.apple.JavaScriptCore 0x96817e... [/quote]
You did cut off the call stack. The important part are the first lines from top to bottom which carry the name of your application. So somewhere after 54 com.apple.JavaScriptCore it will say something like nnn fornext.debug … . These are the interesting parts from your application where the crash starts.