5.5.3 ThreadLocalDemo的结构

Open
#151 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
45/100
Issue type
Documentation
Clarity
Mostly clear
Activity status
Stale
Tech stack
java
Domain
documentation

Research direction

Start with the 第一篇5.5.3 ThreadLocalDemo example and compare the displayed nesting of ThreadA and ThreadB with the references in main. Confirm the intended class structure and correct the documentation so the example consistently names both runnable classes and their relationship.

Written by the indexing model from the issue text.

Description

章节
第一篇5.5.3 ThreadLocalDemo

相关截图或文字

public class ThreadLocalDemo {
    static class ThreadA implements Runnable {
        ...
        static class ThreadB implements Runnable {
              ...
        }

        public static void main(String[] args) {
            ThreadLocal<String> threadLocal = new ThreadLocal<>();
            new Thread(new ThreadA(threadLocal)).start();
            new Thread(new ThreadB(threadLocal)).start();
        }
    }
}

疑问
这里ThreadB类是定义在了ThreadA类里面,是否可以将ThreadB和ThreadA并列:

public class ThreadLocalDemo {
       static class ThreadA implements Runnable {...}
       static class ThreadA implements Runnable {...}
       public static void main(String[] args) {
            ThreadLocal<String> threadLocal = new ThreadLocal<>();
            new Thread(new ThreadA(threadLocal)).start();
            new Thread(new ThreadB(threadLocal)).start();
        }
}
Dominant language
Java
Stars
4.6k
Forks
719
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from RedSpider1/concurrent

All issues in RedSpider1/concurrent

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.