int func(int n){
ロック
ループ
アンロック
return 結果;
}