From aedd569a4cb9ab4e166af5c61bf73a96b3eb7714 Mon Sep 17 00:00:00 2001 From: chegar Date: Mon, 23 Aug 2010 14:35:22 +0100 Subject: [PATCH] 6968584: Thread should not be Cloneable Reviewed-by: dholmes --- src/share/classes/java/lang/Thread.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/share/classes/java/lang/Thread.java b/src/share/classes/java/lang/Thread.java index c379ec591..c3592cf5c 100644 --- a/src/share/classes/java/lang/Thread.java +++ b/src/share/classes/java/lang/Thread.java @@ -413,6 +413,18 @@ class Thread implements Runnable { tid = nextThreadID(); } + /** + * Throws CloneNotSupportedException as a Thread can not be meaningfully + * cloned. Construct a new Thread instead. + * + * @throws CloneNotSupportedException + * always + */ + @Override + protected Object clone() throws CloneNotSupportedException { + throw new CloneNotSupportedException(); + } + /** * Allocates a new {@code Thread} object. This constructor has the same * effect as {@linkplain #Thread(ThreadGroup,Runnable,String) Thread} -- GitLab