Multithreaded external (Win32)?

Aug 4, 2012 at 1:40am

Multithreaded external (Win32)?

I have a Max external project which connects to a Wiimote and creates a secondary thread where I attempt to update the acceleration data and output the results to an outlet during each update frame. This seems to generate an access read violation at the following line:

outlet_anything(data->sender->m_outlet[1], gensym("accel"), 3, av);

I implemented a critical section in hopes that it would correct the issue, but it still fails. Does anyone have a working example of a multithreaded Max object? Is multithreading even allowed?

EDIT: Oops, I meant to post this in the Dev forum.

Aug 4, 2012 at 3:34am

I figured out what I was doing wrong. I should’ve been using the built-in Max threading and critical functions defined in ext_systhread.h and ext_critical.h, respectively. Before, I was using CreateThread() and EnterCriticalSection()/LeaveCriticalSection() as defined in the Windows headers.

Aug 4, 2012 at 5:38am


i’m not used with win32 but afaik you can create thread as you want and use locks you need ; but main problem is to interract with Max API ; specially oultet calls. We currently have a topic about that :

If the max threading API (wrapper for POSIX / win32) is an option for your project, use it for portability ; and you should have a look on the SDK’s simplethread.c example to manage outlet calls with “qelem” task.


I moved your topic to dev.


You must be logged in to reply to this topic.