Thread safety object - static or not?

后端 未结 6 2009
故里飘歌
故里飘歌 2021-01-11 15:09

I was recently in an interview and the tech guy asked me about how to make an application thread-safe.

Well, after explaining the lock() correctly, he s

6条回答
  •  南方客
    南方客 (楼主)
    2021-01-11 15:22

    He claimed the reason is that static is run at runtime instead of compilation and would make that object slower for threads to lock than if it was non static.

    This doesn't really make any sense - I think either the interviewer did not know what he was talking about, or maybe you misunderstood his point.

提交回复
热议问题