        void execute()
        {
            for (size_t i = 0; i < data.size(); i++)
            {
                int partNumber = data[i]->partNumber;
                int partType = partTypes[partNumber];

                if (partType == 0)
                {
                    OutputPart part(*file, partNumber);
                    part.writePixels();
                }
                else
                {
                    int tx = data[i]->tx;
                    int ty = data[i]->ty;
                    int lx = data[i]->lx;
                    int ly = data[i]->ly;
                    TiledOutputPart part(*file, partNumber);

                    //
                    // We add lock here to assure that two threads that accessing
                    // the same part won't mess things up.
                    //

                    Lock lock(mutexes[partNumber]);

                    part.setFrameBuffer(tiledFrameBuffers[partNumber][ly][lx]);
                    part.writeTile(tx, ty, lx, ly);
                }
            }
        }
        void execute()
        {
            for (size_t i = 0; i < data.size(); i++)
            {
                int partNumber = data[i]->partNumber;
                int partType = partTypes[partNumber];

                if (partType == 0)
                {
                    OutputPart part(*file, partNumber);
                    part.writePixels();
                }
                else
                {
                    int tx = data[i]->tx;
                    int ty = data[i]->ty;
                    int lx = data[i]->lx;
                    int ly = data[i]->ly;
                    TiledOutputPart part(*file, partNumber);

                     
                     
                     
                     

                    Lock lock(mutexes[partNumber]);

                    part.setFrameBuffer(tiledFrameBuffers[partNumber][ly][lx]);
                    part.writeTile(tx, ty, lx, ly);
                }
            }
        }