View RSS Feed

Thread

Threads in Java. Java multithreading examples.

  1. Thread Creation

    by , 01-08-2012 at 12:12 PM
    Threads can be created using one of the following methods.

    • By Extending Thread class.
    • By Implementing Runnable interface.

    Java Code: Thread creation
    class Counter extends Thread {
    //method where the thread execution will start
    public void run(){
    //logic to execute in a thread
    }
    //let’s see how to start the threads
    public static void main(String[] args){
    Thread t1 = new Counter();
    Thread t2 = new Counter();
    ...

    Updated 01-14-2012 at 06:52 PM by Thread

    Categories
    Tutorial