23 lines
723 B
Java
23 lines
723 B
Java
import java.util.concurrent.BlockingQueue;
|
|
import java.util.concurrent.LinkedBlockingQueue;
|
|
|
|
public class SquareKaro
|
|
{
|
|
public static void main(String[] args)
|
|
{
|
|
BlockingQueue<Integer> number = new LinkedBlockingQueue<>();
|
|
BlockingQueue<SquareResult> result = new LinkedBlockingQueue<>();
|
|
Squarer mysquarer = new Squarer(number, result);
|
|
mysquarer.start();
|
|
try
|
|
{
|
|
System.out.println("Hey another process, give me square of => 54");
|
|
number.put(54);
|
|
System.out.println(result.take());
|
|
}
|
|
catch(Exception e)
|
|
{
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
} |