miércoles, 10 de marzo de 2021

lunes, 1 de marzo de 2021

Opinion Black Mirror Entire History of you

Do you know Black Mirror serie watched on Netflix?

The series is set in the near future, where technology pervades most of our actions. In the chosen episode, a memory chip implanted in people's heads systematically marks their lives and conditions them substantially. It is an oval or pill-shaped mini-computer, installed behind the right ear, connected to the brain and its eyes, with which it is possible to store up to three decades of memories, the device continuously records everything we see.

Users of such a device have the ability to visualise any memory either through their eyes or through a screen to share those memories with anyone. The device is installed from the time you are a baby, and your parents can access your memories until you reach the age of majority.

One of the curiosities that we can find in this chapter is that "Robert Downey Jr." bought the rights to the chapter in 2013, his idea was to adapt the story to film, however, after a few years, the idea never materialised.


The main plot of the film is very interesting to me, the human being has a limited memory, sometimes, it can even "fool us" or remember something slightly different to what we really lived or learnt and the worst, unfortunately it is very volatile, we suffer it in exam time for students, in our jobs or our personal lives when we forget the name of an old friend we haven't seen for a long time or, who didn't think that we didn't lock the car when we left, didn't roll up the windows perhaps, or simply, what did we have for dinner last night? But this technology that the series offers us is not only nourished by forgetting, what if we could remember every moment that first love? that first kiss? that first goal we scored when we were young? it would indeed be marvellous. As we will see throughout this work, if such technology existed, our lives would change radically, probably professionals such as "judge", "police" and even "examiner", would change radically, what would be the sense of a jury trial, it would only be necessary to access the memories of the person and we would know if we are facing a rapist, murderer, terrorist or simply a man innocent of any charge.

But it's not all positive, is it? What about privacy? What about the need to forget? Can you imagine being over and over again reliving moments with loved ones who are no longer alive? That probably wouldn't even let us move on in life. Can you imagine a gathering of friends? Who would dare to make a joke and have everyone remember it perfectly on their "pimples" (as the mini-computer is colloquially called in the series)?

Throughout the paper I will be analysing the chronology of what happened in the series from my point of view, of course, reviewing the current laws against privacy and recording of current images, in order, of course, to go towards the epicentre of the paper, which is to try to pass a law that includes this technology and helps us to live with it, as this compulsory paper of the subject proposes.


JAVA: Ejercicio sobre threads

 El enunciado es: Implementar el modelo del productor / consumidor.

La solución aportada no comprueba el tamaño del buffer, considera que nunca se va a llenar tanto el buffer como para que falle el programa por desbordamiento (supone que los consumidores se encargarán de variar el buffer para que no se llene demasiado). Puede que esto no sea correcto en algunos entornos y sea necesario controlar la inserción de elementos en el buffer.

Buffer.java
package productorconsumidor;

import java.util.LinkedList;

class Buffer {

    private LinkedList<Integer> num = new LinkedList<>();

    synchronized void poner(int i) {
        num.add(i);
        notify();
    }

    synchronized int quitar() {
        while (num.size() < 1) {
            try {
                wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        return (int) num.remove();
    }
}

Consumidor.java

package productorconsumidor;

class Consumidor extends Thread {

    private Buffer b;

    Consumidor(Buffer b) {
        this.b = b;
    }

    public void run() {
        while (true) {
            System.out.println("Se quita " + b.quitar() + " desde " + getId());
            try {
                Thread.sleep((long) (Math.random() * 4000 + 1));
            } catch (InterruptedException ex) {  }
        }
    }
}

Productor.java

package productorconsumidor;

class Productor implements Runnable {

    private Buffer b;

    Productor(Buffer b) {
        this.b = b;
    }

    public void run() {
        int i = 0;
        while (true) {
            try {
                Thread.sleep((long) (Math.random() * 1000 + 1));
            } catch (InterruptedException ex) { }        
            System.out.println("Se pone " + i++);
            b.poner(i);
        }
    }
}

ProductorConsumidor.java

package productorconsumidor;


public class ProductorConsumidor {

    public static void main(String[] args) {
        Buffer b = new Buffer();
        new Thread(new Productor(b)).start();
        new Consumidor(b).start();
        new Consumidor(b).start();
        new Consumidor(b).start();
    }
}

Puedes ver todos mis ejercicios de JAVA en este enlace.