I cant use Juce_Thread

I am using VS2010 and I want to start a Thread in my VST Plugin.  (In the PluginProcessor.cpp --> in the processBlock)

My Problem is that my Compiler tell my everytime that the Thread class has not a Default Constructor. (Juce_thead.h)

And I am searching for a long time but I cant find anything.


Thanks a lot for your help



A default constructor is a constructor which needs no arguments. When you create a subclass the super class is automatically constructed (simplified). You do this, because Juce::Thread is pure virtual and you do want to override the run method.

The Thread can not be constructed implicitly, because it needs an argument, see http://www.juce.com/doc/classThread
 where you need to specify a thread name. The constructor looks like this:

MyThread::MyThread() : Thread ("anyDefaultName")


// or nicer
MyThread::MyThread (const String& threadName) : Thread (threadName)



BTW. don't create a thread in the processBlock, you will most likely block the audio thread and create buffer underruns. The golden rule is not to create any object, allocate memory or do anything like it in the processBlock method (unless you know exactly what you do, but avoid it at all cost).

You rather create it in the prepareToPlay method (remember this might be called several times) and only shuffle date in the processBlock into your thread.

And also be warned that you access data from different threads, which needs special precautions. Definitely take the time to watch Timur's talk at the CPP convention: http://www.juce.com/forum/topic/timurs-cppcon-presentation or directly to youtube: https://youtu.be/boPEO2auJj4

Thanks a lot 

Its my first time that I create a VST Plugin. 
I decide to write in the ProcessBlock because I have to wait until the Buffer is full enough to calculate in my algorithm.
It is not easy to create a good Vst Plugin -_- 
I thought if the buffer == maxSize then startThread --> Algorithm function and that every time every time.

Maybe my idea of this solution is not right :(

Yeah, sounds like you're very far from right about how to approach it. It's generally unwise to use threads in plugins unless you're an expert and really know what you're doing.

Very hard to give you a one-sentence explanation that might help you get on the right track, but I'm guessing a FIFO might be what you need?

Maybe somebody can help me if I show my UML-Diagram.
I thought it will be easy because I have experience with C++ but I never worked with Audio Signals before.

I thank everybody who can be able to help me

There is another thread about multi threading, especially this comment is helpful: http://www.juce.com/comment/317267#comment-317267

Thanks a lot for your help 

I will try some other things until it will work correctly 

Best Regards