2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2016-2018 Ericsson. All rights reserved.
4 * Modifications Copyright (C) 2020 Nordix Foundation.
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.apex.core.infrastructure.threading;
24 import org.slf4j.ext.XLogger;
25 import org.slf4j.ext.XLoggerFactory;
27 import java.util.concurrent.CountDownLatch;
30 * The Class ThreadingTestThread.
32 * @author Liam Fallon (liam.fallon@ericsson.com)
34 public class ThreadingTestThread implements Runnable {
36 // Logger for this class
37 private static final XLogger logger = XLoggerFactory.getXLogger(ThreadingTestThread.class);
39 private boolean interrupted = false;
41 private long counter = -1;
43 private String threadName;
45 private CountDownLatch latch = new CountDownLatch(1);
52 this.threadName = Thread.currentThread().getName();
53 if (logger.isDebugEnabled()) {
54 logger.debug("starting threading test thread \"" + threadName + "\" . . .");
57 while (!interrupted) {
59 if (logger.isDebugEnabled()) {
60 logger.debug("in threading test thread \"" + threadName + "\", counter=" + counter + " . . .");
62 if(!ThreadUtilities.sleep(50)) {
67 if (logger.isDebugEnabled()) {
68 logger.debug("stopped threading test thread \"" + threadName + "\"");
77 public String getName() {
84 public void interrupt() {
93 public Long getCounter() {