• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Hyshmily / hotkey / 28637103998

03 Jul 2026 03:48AM UTC coverage: 90.399% (-0.2%) from 90.63%
28637103998

push

github

Hyshmily
fix: add packaging to gitignore, fix flaky jitter test, update docs references

Signed-off-by: Hyshmily <cxm8607@outlook.com>

1264 of 1461 branches covered (86.52%)

Branch coverage included in aggregate %.

3604 of 3924 relevant lines covered (91.85%)

4.19 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

83.33
/common/src/main/java/io/github/hyshmily/hotkey/util/HotKeyThreadFactory.java
1
/*
2
 * Copyright 2026 Hyshmily. All Rights Reserved.
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package io.github.hyshmily.hotkey.util;
17

18
import io.github.hyshmily.hotkey.Internal;
19
import java.util.concurrent.ThreadFactory;
20
import java.util.concurrent.atomic.AtomicInteger;
21
import org.jspecify.annotations.NonNull;
22

23
/**
24
 * A named, daemon-mode {@link ThreadFactory} used consistently across all HotKey
25
 * thread pools. Every created thread is a daemon thread with
26
 * {@link Thread#NORM_PRIORITY} and a human-readable name prefix for diagnostics.
27
 * <p>
28
 * Thread names follow the pattern {@code <namePrefix><N>} where {@code N} is an
29
 * auto-incrementing counter starting at 1 (e.g. {@code hotkey-scheduler-1}).
30
 */
31
@Internal
32
public class HotKeyThreadFactory implements ThreadFactory {
33

34
  private final ThreadGroup group;
35
  private final AtomicInteger threadNumber = new AtomicInteger(1);
6✔
36
  private final String namePrefix;
37

38
  /**
39
   * Creates a factory whose threads will be named {@code <namePrefix><N>}.
40
   *
41
   * @param namePrefix the prefix for all thread names created by this factory
42
   *                   (e.g. {@code "hotkey-scheduler-"})
43
   */
44
  public HotKeyThreadFactory(String namePrefix) {
2✔
45
    this.group = Thread.currentThread().getThreadGroup();
4✔
46
    this.namePrefix = namePrefix;
3✔
47
  }
1✔
48

49
  @Override
50
  public Thread newThread(@NonNull Runnable r) {
51
    Thread t = new Thread(group, r, namePrefix + threadNumber.getAndIncrement(), 0);
14✔
52
    t.setDaemon(true);
3✔
53
    if (t.getPriority() != Thread.NORM_PRIORITY) {
4!
54
      t.setPriority(Thread.NORM_PRIORITY);
×
55
    }
56
    return t;
2✔
57
  }
58
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc