1 /*
2 * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
396 // (we wait for this time twice,
397 // once for dispose(), and once
398 // to clear the EventQueue).
399
400 private long THREAD_INTERRUPT_TIMEOUT = 1000;
401 // Default to 1-second timeout for all
402 // interrupted Threads to exit, and another
403 // 1 second for all stopped Threads to die.
404
405 /**
406 * Disposes of this AppContext, all of its top-level Frames, and
407 * all Threads and ThreadGroups contained within it.
408 *
409 * This method must be called from a Thread which is not contained
410 * within this AppContext.
411 *
412 * @exception IllegalThreadStateException if the current thread is
413 * contained within this AppContext
414 * @since 1.2
415 */
416 public void dispose() throws IllegalThreadStateException {
417 // Check to be sure that the current Thread isn't in this AppContext
418 if (this.threadGroup.parentOf(Thread.currentThread().getThreadGroup())) {
419 throw new IllegalThreadStateException(
420 "Current Thread is contained within AppContext to be disposed."
421 );
422 }
423
424 synchronized(this) {
425 if (this.state != State.VALID) {
426 return; // If already disposed or being disposed, bail.
427 }
428
429 this.state = State.BEING_DISPOSED;
430 }
431
432 final PropertyChangeSupport changeSupport = this.changeSupport;
433 if (changeSupport != null) {
434 changeSupport.firePropertyChange(DISPOSED_PROPERTY_NAME, false, true);
435 }
|
1 /*
2 * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
396 // (we wait for this time twice,
397 // once for dispose(), and once
398 // to clear the EventQueue).
399
400 private long THREAD_INTERRUPT_TIMEOUT = 1000;
401 // Default to 1-second timeout for all
402 // interrupted Threads to exit, and another
403 // 1 second for all stopped Threads to die.
404
405 /**
406 * Disposes of this AppContext, all of its top-level Frames, and
407 * all Threads and ThreadGroups contained within it.
408 *
409 * This method must be called from a Thread which is not contained
410 * within this AppContext.
411 *
412 * @exception IllegalThreadStateException if the current thread is
413 * contained within this AppContext
414 * @since 1.2
415 */
416 @SuppressWarnings("deprecation")
417 public void dispose() throws IllegalThreadStateException {
418 // Check to be sure that the current Thread isn't in this AppContext
419 if (this.threadGroup.parentOf(Thread.currentThread().getThreadGroup())) {
420 throw new IllegalThreadStateException(
421 "Current Thread is contained within AppContext to be disposed."
422 );
423 }
424
425 synchronized(this) {
426 if (this.state != State.VALID) {
427 return; // If already disposed or being disposed, bail.
428 }
429
430 this.state = State.BEING_DISPOSED;
431 }
432
433 final PropertyChangeSupport changeSupport = this.changeSupport;
434 if (changeSupport != null) {
435 changeSupport.firePropertyChange(DISPOSED_PROPERTY_NAME, false, true);
436 }
|