- Main thread starts first and initiates the other threads.

- JVM shutsdown when all the users threads are terminated.

- start()

- yield()

- run()

- sleep()

- Threads can be instantiated by extending thread.class or by implementing runnable interface();

- Extending the thread is worker and implementing the runnable is job. So we have to pass this runnable job to some worker ie thread.

MyRunnable mr = new MyRunnable();

Thread t = new Thread(mr);


Thread Constructors 


Thread(Runnable r)

Thread(Runnable r, String s)

Thread(String s)

-  getState() shows the state of the thread

- isAlive() method shows the alive status of the thread.

- Thread.currentThread() returns the instance of current executing thread.

- join() method waits till the execution of some other thread

- A thread can be started only once.. ie a runnable thread cannot be restarted.

-  Methods that help thread scheduling are as follows :

- sleep

- yield

- join

- setPriority(int priority)

- wait() 

- notify()

- notifyAll()

- Thread methods which allows the thread to enter block state are -

1) sleep

2) Waiting for some resource

Thread.currentThread(int milli) - ensures that particular thread will sleeps atleast for x millis.

Checked exception InterruptedException is to be handled during the thread.sleep();

yield() - graceful return to the same priority threads.Yield() method may put the running thread into runnable state. But 

the behaviour is not guarenteed. 

- There are three static final constants defined in Thread class to define priority.

viz : 1) Thread.MIN_PRIORITY = 1

2) Thread.NORM_PRIORITY = 5

3) Thread.MAX_PRIORITY =10

- Join() method is non-static and it allows the current thread to run after the successful excecution of the present thread

ALL about SCJP = SCJP 1.6, mock, certification, scjp 1.5 , scjp questions, scjp books, scjp hand written notes, scjp dumps, scjp trainings, scjp video tutorials, scjp simulators etc.