using System;
using System.Collections;
namespace Recetas.CSharp.R0414
{
public sealed class UsoSynchronized
{
public static void Main()
{
// Creación de una instancia de `Queue`:
Queue q = new Queue();
// Adición de datos:
q.Enqueue ("Experiencias");
q.Enqueue ("Construcción");
q.Enqueue ("Software");
q.Enqueue ("xCSw");
// Crea una versión sincronizada a través
// del método estático `Synchronized`:
Queue qSincronizado = Queue.Synchronized (q);
// Muestra el estado de las dos objetos `Queue`:
Console.WriteLine ("\n`q` {0}está sincronizado.",
q.IsSynchronized ? "" : "no "
);
Console.WriteLine ("`qSincronizado` {0}está sincronizado.\n",
qSincronizado.IsSynchronized ? "" : "no "
);
}
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uQ29sbGVjdGlvbnM7CgpuYW1lc3BhY2UgUmVjZXRhcy5DU2hhcnAuUjA0MTQKewogICAgcHVibGljIHNlYWxlZCBjbGFzcyBVc29TeW5jaHJvbml6ZWQKICAgIHsKICAgICAgICBwdWJsaWMgc3RhdGljIHZvaWQgTWFpbigpCiAgICAgICAgewogICAgICAgICAgICAvLyBDcmVhY2nDs24gZGUgdW5hIGluc3RhbmNpYSBkZSBgUXVldWVgOgogICAgICAgICAgICBRdWV1ZSBxID0gbmV3IFF1ZXVlKCk7CiAgICAgICAgICAgIAogICAgICAgICAgICAvLyBBZGljacOzbiBkZSBkYXRvczoKICAgICAgICAgICAgcS5FbnF1ZXVlICgiRXhwZXJpZW5jaWFzIik7CiAgICAgICAgICAgIHEuRW5xdWV1ZSAoIkNvbnN0cnVjY2nDs24iKTsKICAgICAgICAgICAgcS5FbnF1ZXVlICgiU29mdHdhcmUiKTsKICAgICAgICAgICAgcS5FbnF1ZXVlICgieENTdyIpOwogICAgICAgICAgICAKICAgICAgICAgICAgLy8gQ3JlYSB1bmEgdmVyc2nDs24gc2luY3Jvbml6YWRhIGEgdHJhdsOpcyAKICAgICAgICAgICAgLy8gZGVsIG3DqXRvZG8gZXN0w6F0aWNvIGBTeW5jaHJvbml6ZWRgOgogICAgICAgICAgICBRdWV1ZSBxU2luY3Jvbml6YWRvID0gUXVldWUuU3luY2hyb25pemVkIChxKTsKICAgICAgICAgICAgCiAgICAgICAgICAgIC8vIE11ZXN0cmEgZWwgZXN0YWRvIGRlIGxhcyBkb3Mgb2JqZXRvcyBgUXVldWVgOgogICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSAoIlxuYHFgIHswfWVzdMOhIHNpbmNyb25pemFkby4iLCAKICAgICAgICAgICAgICAgIHEuSXNTeW5jaHJvbml6ZWQgPyAiIiA6ICJubyAiCiAgICAgICAgICAgICk7CiAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lICgiYHFTaW5jcm9uaXphZG9gIHswfWVzdMOhIHNpbmNyb25pemFkby5cbiIsIAogICAgICAgICAgICAgICAgcVNpbmNyb25pemFkby5Jc1N5bmNocm9uaXplZCA/ICIiIDogIm5vICIKICAgICAgICAgICAgKTsKICAgICAgICB9CiAgICB9Cn0=