Submitted by heartin on Thu, 10/15/2015 - 12:39
Problem
Create two threads - one that prints odd numbers till 10 in the format "Odd 1", "Odd 3" etc. and one that prints even numbers till 10 in the format "Even 0", "Even 2" etc..
Need to implement coordination between them so that the output will be:
Even0
Odd1
Even2
Odd3
Even4
Odd5
Even6
Odd7
Even8
Odd9
Even10
Submitted by heartin on Wed, 10/14/2015 - 21:33
Java.lang.Object provides three methods – notify(), notifyAll() and wait () – to improve the efficiency communication between threads. You will need to understand the synchronization process in Java to understand the communication using wait, notify and notifyAll.
Submitted by heartin on Wed, 10/14/2015 - 21:03
You can create threads directly instantiating a Thread class or using the newer better and safer concurrency package features such as Executors.
Though it is not preferred to create threads directly in new code, learning to create threads directly working with Thread class helps to understand basics well.
We can create a Thread by
Submitted by heartin on Wed, 10/14/2015 - 20:59
A daemon thread is a background thread and dies when the thread that created it ends.
A thread that is not daemon is called a user thread.
We can make a thread as daemon thread by calling setDaemon (true) on the thread instance.
We can call setDaemon() for a thread only before it starts, else an IllegalThreadStateException will be thrown.
Example:
MyThread t1= new MyThread ();
t1.setDaemon(true);
t1.start();
Submitted by heartin on Tue, 10/13/2015 - 06:48
Java supports both SOAP-based and REST-style web services.
JAX-WS
Pages