M
Miles
Hi all,
Reading over threads in the Concurrency trail on Sun's tutorials and noticed the
following:
public class ProducerConsumerExample {
public static void main(String[] args) {
Drop drop = new Drop();
(new Thread(new Producer(drop))).start();
(new Thread(new Consumer(drop))).start();
}
}
Curious as to why the presence of the outer parenthesis? Is the line casting
the Producer as a "new thread".
If so, why is it necessary instead of just using new by itself? Is it because
the object is instantiated directly and not being assigned to a variable?
Thanks for clarification.
Reading over threads in the Concurrency trail on Sun's tutorials and noticed the
following:
public class ProducerConsumerExample {
public static void main(String[] args) {
Drop drop = new Drop();
(new Thread(new Producer(drop))).start();
(new Thread(new Consumer(drop))).start();
}
}
Curious as to why the presence of the outer parenthesis? Is the line casting
the Producer as a "new thread".
If so, why is it necessary instead of just using new by itself? Is it because
the object is instantiated directly and not being assigned to a variable?
Thanks for clarification.