Memory scope of List in Thread

I am writing a class in which I have a List. And I am instantiating the list from the run method of `Runnable`. As: public void sendEmailToLegalUsers() {"JYM===================================="); try { new Runnable() { public void run() { userCns = new ArrayList(); recipients = new ArrayList(); ///other codes } }; } catch (Exception e) {"Error occurred in LDAPSendMail: "+ e.getMessage()); }"END===================================="); } Now each time the sendEmailToLegalUsers method will be called there will be a new thread. Now I am wondering is the memory scope of the list is bounded to class level (if it is bounded to class level and if say this method is called two times then what will happen of the list which is created by Thread 1 when there is also a Thread 2) or as the threads run in their own scope then the list will have different scope for each thread. Is there any chance to mixup of the list data between two or multiple thread?

以上就是Memory scope of List in Thread的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准