Mutex doesn't work
<p>My code is an AVL tree and am trying to enter with <code>mutex</code>.</p>

<p>The <code>mutex</code> does not work. Why? </p>

<p>Return black screen, perhaps a deadlock.
I don't know.
Not exist recursive functions. </p>

<p>If I use a <code>lock guard</code> it works normally.</p>

<pre><code>template&lt;typename T&gt; int avl&lt;T&gt;::insere (int key , T data) {

    mtx.lock();

    no * nw = new no;

    if (nw == NULL)
        return 0;

    nw-&gt;sire = NULL;
    nw-&gt;left = NULL;
    nw-&gt;right = NULL;
    nw-&gt;key = key;
    nw-&gt;data = data;

      if (tree.root == NULL) {
        tree.root = nw;
        tree.quant++;
        return 1;
    }
    no * son = tree.raiz;
    no * sire  = NULL;

    while (son != NULL) {

        sire = son;

        if (key &lt; son-&gt;key)
            son = son-&gt;left;

        else
            son = son-&gt;right.;

    }
    nw-&gt;sire = sire;

    if (key &lt; sire-&gt;key)
        sire-&gt;left = nw;

    else
        sire-&gt;right = nw;

    tree.quantidade++;

    no * current = nw;

    while (current != NULL) {

        int f = fator (nw);

        if (f &gt;= 2 || f &lt;= 2)
            balance( current);
        current = current-&gt;sire;
    }

    mtx.unlock();

    return 1;
}
</code></pre>