0

私の質問は、Spring コントローラー (最終的にはサーブレット クラス) のスレッドセーフに関するものです。

1) 変数 static final int i =0 を定義すると、スレッドセーフの問題が発生しますが、static と final を宣言しました 2) enum を protected enum Mytype{start, stop} のようなグローバル変数として宣言するのはどうですか? 3) @Autowired のデカールはスレッドセーフですか?

これに関する良い記事を見つけましたが、上記の質問についてもっと明確にする必要があります。 参照

コード:

@Controller
Public class Test{
@Autowired MyTest mt;  // Autowired, thread safe?
private final String s = "abc"; // final, threadsafe?
private static final int i =0; // again final threadsafe?
private static int x = 0; // only static threadsafe?    
protected enum Mytype{head, tail}; // enum, threadsafe?
.....
}
4

1 に答える 1