Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7494539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T17:37:21+00:00 2026-05-29T17:37:21+00:00

I have made two thread running together with Netbeans and i want to add

  • 0

I have made two thread running together with Netbeans and i want to add three buttons for stop-pause-continue them.They highlight and de-highlight a text.The code for one of them is

class TimeHighspell extends Thread{
    int x=0;
    int pos;
    int delay;
    Control control ;
    String [] result;
    int[] anArray;
    public TimeHighspell (Control c, int delay,String [] result1,int pos,int[] anArray) {
        x=0;
        control = c;
        this.delay = delay;
        result=result1;
        this.pos=pos;
        this.anArray=anArray;
    }
public void run(){
    while (true) {
        control.putHighspell(result,pos,x);
        int Search=x+1;
        Arrays.sort(anArray);
        int index = Arrays.binarySearch(anArray,Search); 
        if (index > 0) 
            pos=pos+result[x].length()+1;
        else
            pos=pos+result[x].length();
        x=x+1;
        try {
            Thread.sleep( delay );
        }
        catch ( InterruptedException e ) {}
   }}}
class Control {
    private boolean ping = false;
    public synchronized void putHigh(String [] result,int pos,int x){     
       while(ping==false)
            try{
                //notify();
                wait();
            }catch( InterruptedException e){}
        highlight(editPane, result[x],pos);
        HighBold(editPane,result[x],pos);
        ping = false;
        notifyAll();
}

To start them i use a a button where i put this code

 private void HighWordActionPerformed(java.awt.event.ActionEvent evt) {                                         
    String [] result1 = editPane.getText().split("\\s");
    Control c = new Control();
    int delay;
    int pos=0;
    delay=Slider.getValue();
    RemoveHigh p1 = new RemoveHigh(c, delay);
    TimeHigh c1 = new TimeHigh(c, delay,result1,pos);
    p1.start();
    c1.start();}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T17:37:23+00:00Added an answer on May 29, 2026 at 5:37 pm

    Finally i used logical flags following and older answer from @Roman
    How to indefinitely pause a thread in Java and later resume it?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have these two images. And... I made them into graysclae images and then
I have an object and I want to delay an operation. I made two
Alongside the implicit User Interface thread, i have made two threads (runnables), both having
I have two UITextFields in the App as IBOutlets and I have made a
I have made a list view containing two childs. Now i am trying to
I have made a simple test application for the issue, two winforms each containing
I have two branches: trunk, production. I have found a problem in trunk, made
I currently have a Rails 3.0.10 app and I made two models with simple
I have two classes. In Class1 I have a thread and in Class2 I
So, I have two threads. Thread one manages the client connections. (There is only

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.