Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

异常类

class IllegalSynchronizationStateException

public class IllegalSynchronizationStateException <: Exception {
    public init()
    public init(message: String)
}

功能:此类为非法同步状态异常。

父类型:

init()

public init()

功能:创建一个 IllegalSynchronizationStateException 实例。

示例:

import std.sync.*

main(): Unit {
    // 抛出一个 IllegalSynchronizationStateException 实例
    try {
        throw IllegalSynchronizationStateException()
    } catch (e: IllegalSynchronizationStateException) {
        println("捕获到异常: ${e}")
    }
}

运行结果:

捕获到异常: IllegalSynchronizationStateException

init(String)

public init(message: String)

功能:创建一个 IllegalSynchronizationStateException 实例,其信息由参数 message 指定。

参数:

  • message: String - 预定义消息。

示例:

import std.sync.*

main(): Unit {
    // 抛出一个 IllegalSynchronizationStateException 实例
    try {
        throw IllegalSynchronizationStateException("非法同步状态异常")
    } catch (e: IllegalSynchronizationStateException) {
        println("捕获到异常: ${e}")
    }
}

运行结果:

捕获到异常: IllegalSynchronizationStateException: 非法同步状态异常