Mostrando entradas con la etiqueta threads. Mostrar todas las entradas
Mostrando entradas con la etiqueta threads. Mostrar todas las entradas

sábado, 25 de noviembre de 2023

What is the tech stack for the shortern future?

Predicting the exact technology stack for the future can be challenging because technology evolves rapidly, and new innovations constantly emerge. However, there are some trends and technologies that have been gaining traction and are likely to play a significant role in the tech stacks of the future. Keep in mind that the specific stack you choose will depend on your project's requirements and goals. Here are some key trends and technologies to consider:


  • Cloud Computing: Cloud platforms like Amazon Web Services (AWS), Microsoft Azure, and Google Cloud are expected to continue dominating the cloud computing landscape. Serverless computing and containerization (using technologies like Docker and Kubernetes) will likely become even more important for scalability and efficiency.

  • Edge Computing: As IoT devices become more prevalent, edge computing will grow in importance. This involves processing data closer to the source (i.e., the "edge" of the network) to reduce latency and improve real-time decision-making.

  • Artificial Intelligence (AI) and Machine Learning (ML): AI and ML will continue to be integrated into various applications and services. Frameworks like TensorFlow and PyTorch will remain important, and AI/ML models will be increasingly deployed at the edge for faster processing.

  • Blockchain: While blockchain technology is primarily associated with cryptocurrencies like Bitcoin, it has applications beyond finance, such as supply chain management, voting systems, and more. Blockchain platforms like Ethereum and Hyperledger are likely to see continued development and adoption.

  • Quantum Computing: Quantum computing is still in its infancy, but it holds great promise for solving complex problems that are currently beyond the capabilities of classical computers. Companies like IBM and Google are actively working on quantum computing research.

  • 5G Technology: The rollout of 5G networks will enable faster and more reliable wireless connectivity. This will impact various industries, including IoT, autonomous vehicles, augmented reality, and virtual reality.

  • Cybersecurity: With the increasing importance of digital data and connectivity, cybersecurity will remain a top concern. Technologies like AI-driven threat detection, zero-trust security models, and encryption will continue to evolve.

  • Web Technologies: JavaScript, HTML, and CSS will remain fundamental for web development, but frameworks like React, Angular, and Vue.js are likely to continue their popularity. Progressive Web Apps (PWAs) and WebAssembly are also promising technologies.

  • DevOps and Automation: DevOps practices, along with tools like Jenkins, Docker, and Ansible, will continue to streamline development, deployment, and operations processes. Automation will be critical for efficiency and reliability.

  • Sustainability: Sustainability considerations will play a larger role in tech stacks. Energy-efficient hardware, green data centers, and eco-friendly software development practices will become more important.

  • AR/VR: Augmented reality (AR) and virtual reality (VR) technologies will continue to advance, with applications in gaming, education, healthcare, and more.

  • Natural Language Processing (NLP): NLP technologies like GPT-4 and beyond will enable more sophisticated conversational AI, language translation, and content generation.

  • Container Orchestration: Technologies like Kubernetes and Docker Swarm will remain crucial for managing and scaling containerized applications.



It's essential to stay up-to-date with emerging technologies and adapt your tech stack based on your project's specific needs and the evolving industry trends. Flexibility and a willingness to learn and experiment will be valuable skills for technology professionals in the future. 

lunes, 1 de marzo de 2021

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.

lunes, 6 de enero de 2020

Programa en C que genere 6 hilos y estos se identifiquen

Generemos un programa en lenguaje C que lance o genere 6 hilos y estos se identifiquen con un identificador.





#include <stdio.h>
#include <pthread.h>
#include <unistd.h>

#define NUMERO 6

int contador;
static void *saluda (void *);

int main (void)
{
 int i;
 pthread_t hilo[NUMERO];

 for (i = 0; i < NUMERO ; i++) {
  sleep(1);
  pthread_create (&hilo[i],NULL,saluda,NULL);
 }

 for (i = 0; i < NUMERO ; i++) {

  pthread_join (hilo[i],NULL);
 }

 return 0;
}

static void *saluda (void *args) 
{
 contador += 1;
 printf ("Soy el thread %d y tengo el id %d\n",contador,(int) pthread_self());
 return NULL;
}

lunes, 3 de junio de 2019

Ejemplo completo de Matrices en C

A continuación, os pongo el ejemplo que se me ha ocurrido más completo sobre gestión de Matrices en C que reúne los ejemplos que he ido poniendo anteriormente.




#include <stdio.h>;
#include <stdlib.h>;


void Ingresa_Matriz (int m[3][3], int f, int c);
void Utiliza_Matriz (int m[3][3], int f, int c);
void Visualiza_Matriz (int m[3][3], int f, int c);
void Rota_Matriz_D (int m[3][3], int f, int c);
void Rota_Matriz_I (int m[3][3], int f, int c);
void Multiplica_Matriz (int m[3][3], int f, int c, int cf, int *m0, int *m1, int *m2);

int main () {
    char ingresa;
    int m[3][3], cf = 0, direccion = 0, f = 0, c = 0;
    int m0, m1, m2;
    printf ("Deseas ingresar Matriz o utiliza la maqueta &lt;I/M&gt;: ");
    scanf ("%c",&amp;ingresa);
    if (ingresa == 'i') {
        Ingresa_Matriz(m, f, c);
    } else {
        Utiliza_Matriz(m, f, c);
    }
    Visualiza_Matriz(m, f, c);
    printf ("\nDeseas rotar la matriz a la derecha &lt;1&gt; o a la izquierda &lt;0&gt;: ");
    scanf ("%d",&amp;direccion);
    if (direccion == 1) {
        Rota_Matriz_D (m, f, c);
    } else {
        Rota_Matriz_I (m, f, c);
    }
    Visualiza_Matriz(m, f, c);
    printf ("\n¿Quieres multiplicar las filas (1) o las columnas (0)?: ");
    scanf ("%d",&amp;cf);
    Multiplica_Matriz(m, f, c, cf, &amp;m0, &amp;m1, &amp;m2);
    if (cf == 1) {
        printf ("\nMultiplicacion Fila 0: %d",m0);
        printf ("\nMultiplicacion Fila 1: %d",m1);
        printf ("\nMultiplicacion Fila 2: %d",m2);
    } else {
        printf ("\nMultiplicacion Columna 0: %d",m0);
        printf ("\nMultiplicacion Columna 1: %d",m1);
        printf ("\nMultiplicacion Columna 2: %d",m2);
    }
    return 0;
}

void Ingresa_Matriz (int m[3][3], int f, int c) {
    for (f=0;f&lt;3;++f) {
        for (c=0;c&lt;3;++c) {
            printf ("\nIntroduce posicion [%d][%d]: ",f,c);
            scanf ("%d",&amp;m[f][c]);
        }
    }
}

void Utiliza_Matriz (int m[3][3], int f, int c) {
    for (f=0;f&lt;3;++f) {
        for (c=0;c&lt;3;++c) {
            m[f][c]=rand()%50+1;
        }
    }
}

void Visualiza_Matriz (int m[3][3], int f, int c) {
    for (f=0;f&lt;3;++f) {
        for (c=0;c&lt;3;++c) {
            printf ("[%d] ",m[f][c]);
        } printf ("\n");
    }
}
void Rota_Matriz_D (int m[3][3], int f, int c) {
    int tmp[3][3];
    for (f=0;f&lt;3;++f) {
        for (c=0;c&lt;3;++c) {
                if (c == 2) {
                    tmp[f][0]=m[f][c];
                } else {
                    tmp[f][c+1]=m[f][c];
                }
            }
        }
    for (f=0;f&lt;3;++f) {
        for (c=0;c&lt;3;++c) {
            m[f][c]=tmp[f][c];
        }
    }
}

void Rota_Matriz_I (int m[3][3], int f, int c) {
    int tmp[3][3];
    for (f=0;f&lt;3;++f) {
        for (c=0;c&lt;3;++c) {
            if (c == 0) {
                tmp[f][2]=m[f][c];
            } else {
                tmp[f][c-1]=m[f][c];
            }
        }
    }
    
    for (f=0;f&lt;3;++f) {
        for (c=0;c&lt;3;++c) {
            m[f][c]=tmp[f][c];
        }
    }
}

void Multiplica_Matriz (int m[3][3], int f, int c, int cf, int *m0, int *m1, int *m2) {
    // 1 Multiplica filas
    // 0 Multiplica columnas
    int c0[3], c1[3], c2[3];
    
    if (cf == 0) {
        printf ("\nMultiplicando columnas...\n\n");
        for (f=0;f&lt;3;++f) {
            for (c=0;c&lt;3;++c) {
                if (c == 0)
                    c0[f]=m[f][c];
                if (c == 1)
                    c1[f]=m[f][c];
                if (c == 2)
                    c2[f]=m[f][c];
            }
        }
    } else {
        printf ("\nMultiplicando filas...\n\n");
        for (f=0;f&lt;3;++f) {
            for (c=0;c&lt;3;++c) {
                if (f == 0)
                    c0[c]=m[f][c];
                if (f == 1)
                    c1[c]=m[f][c];
                if (f == 2)
                    c2[c]=m[f][c];
            }
        }
    }
    *m0=c0[0]*c0[1]*c0[2];
    *m1=c1[0]*c1[1]*c1[2];
    *m2=c2[0]*c2[1]*c2[2];
}