View RSS Feed


Threads in Java. Java multithreading examples.

  1. Thread Creation

    by , 01-08-2012 at 01: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 07:52 PM by Thread