module("garbage1")
module("garbage3")

local work = {}

function main()
    printf("started")

    garbage1.init		()
    garbage3.init       ()

    table.insert(work, "garbage1"	)
    table.insert(work, "garbage3"	)

	while(table.getn(work) > 0) do
    	local deleted = {}
        for k,v in work do
            if(v == "garbage1") then
                if(garbage1.execute() == false) then
                    garbage1.finalize()
                    table.insert(deleted, k)
                end
            elseif(v == "garbage3") then
                if(garbage3.execute() == false) then
                    garbage3.finalize()
                    table.insert(deleted, k)
                end
        	end
        end
        for k,v in deleted do
        	table.remove(work, v)
        end

        wait()

   	end
end