Hello everyone,
I was looking for a neat way to create multi threads with Titanium. I eventually found this post http://developer.appcelerator.com/question/117199/how-to-create-multithreading-in-mobile-sdk but thought it was a bit ugly... so I created a little function that does everything for you...
Here it is
function thread(func) { var th = Ti.UI.createWindow(); // Store the event function th.startEv = func; th.addEventListener('start', function() { th.startEv(); th = null; }); th.fireEvent('start'); // To retain the thread return th; }And then the creating threads is easy!
thread(function() { while (true) { Ti.API.error("Some other thread is running without blocking the UI!"); } });Hope this helps someone, adios!





