¡GoConqr estrena diseño! Cuéntanos qué te parece.

Fichas

Thread

Pacifique Mugwaneza java ACT Year 12 Certificate Inglés 7 fichas

Fichas del conjunto (7)

  1. 1How to create a thread, using Thread and execute?public class MyThread extends Thread{
    public void run()
    {
    //code de be executed
    }
    }
    Creation :
    MyThread t = new MyThread();
    t.start();
  2. 2How to create a thread, using Runnable and execute?public class MyRunnable implements Runnable{
    public void run()
    {
    //code de be executed
    public void run()
    {
    }
    }
    Creation :
    MyRunnable r = new MyRunnable();
    Thread t = Thread(r)
    t.start();
  3. 3How to create a thread a Deamon Thread?public class MyThread extends Thread{
    public void run()
    {
    //code de be executed
    }
    }
    Creation :
    MyThread t = new MyThread();
    t.setDeamon(true);
    t.start();
  4. 4How to create a pipe and read it?Creation : Pipe p=Pipe.open();
    Read :
    Pipe.SinkChannel buf = pipe.source();
    ByteBuffer buf = ByteBuffer.allocate(48);
    int bytesRead = intChannel.read(buf);
  5. 5How to create a pipe and write in it?Creation : Pipe p=Pipe.open();
    Write : Pipe.SinkChannel buf = pipe.sink();
    ByteBugger buf = ByteBufer.allocate(48);
    buf.clear();
    buf.put(newData.getBytes());
    buf.flip();
    while(buf.hasRemaining())
    {
    sinkChannel.write(buf);
    }
  6. 6A quoi sert un Synchronized method?A réserver un objet clé, fonction appelable qu'une fois que la clé est libre
    public synchronized void show(){ }
  7. 7comment declarer un Synchronized bloc?il faut fournir en argument l’objet dont la clé du verrou est nécessaire pour y pénétrer.
    synchronized(this) {
    }

Información

Descripción
how to create a thread
Visitas
3
Valoración

Escríbenos

¿Sobre qué es tu mensaje?

¿Qué te parece el nuevo diseño?

¿Te gusta?