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 6847579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:45:43+00:00 2026-05-27T00:45:43+00:00

I was testing a heavy loaded video, which loads the video and after Thread.sleep(1000);

  • 0

I was testing a heavy loaded video, which loads the video and after Thread.sleep(1000); it plays second video. But once i play one after another in loop it freeze.

When i removed all those Thread.sleep(1000); it worked perfectly without freeze.

But i need to make a delay (but not using Thread.sleep method), how can we do this?

package test;

public class Test
{
  static String what = "0";
  public static void main(String args[]) 
  {                    
    Load.video720p("/tmp/START.mp4"); // This is 8 second movie playing
    new javax.swing.Timer(8000, new ActionListener() 
    {
        public void actionPerformed(ActionEvent ae) 
        {
          if (what.equals("0") ) 
          {
            /* After 8 seconds play 0.mp4 */
            callMe();
            what = "1";
          } else {
            /* After 8 seconds play 1.mp4 */
            callMe();
            what = "0";
          }
        }
    }).start(); /* Keep on looping every 8 seconds. */
  }

  /* 8 seconds interval call me. */
  public static void callMe()
  {
      try {

           /* Try 0: Freeze/Do not play */
           Load.video720p("/tmp/" +  what + ".mp4");                  

           /* Try 1: Does not change films (cant run)
           new Thread(new Runnable() {
             public void run() {
            Load.video720p("/tmp/" +  what + ".mp4", EVENT_TRIGGER_TRUE);                  
         }
           });*/

           /* Try 2: Fails
           try {
         javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
               public void run() {
                    Load.video720p("/tmp/" +  what + ".mp4");
               }
         });
        } catch (Exception e) { 
            System.err.println(e);
        }*/

        /* Try 3: Failes
        try {
         java.awt.EventQueue.invokeAndWait(new Runnable() {
                public void run() {
                    Load.video720p("/tmp/" +  what + ".mp4");  
                }
         });
        } catch (Exception e) { 
            System.err.println(e);
        }*/

      } catch (Exception e) {
        System.out.println(e);
      } 
    }
} 
  • 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-27T00:45:44+00:00Added an answer on May 27, 2026 at 12:45 am

    If you’re calling sleep() on the event handling thread, then yes, your GUI will freeze during that time. A better idea is to use a SwingTimer which will allow you to trigger playing of the second video after a specified delay without calling sleep().

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

Sidebar

Related Questions

Unit testing sounds great to me, but I'm not sure I should spend any
We're developing a data heavy modular web application stack with java but have little
My company is engaging with a multivariate testing vendor (I can't disclose which one
When coding new javascript heavy websites, which order or web browser do you code
I wrote a C program in which I did some pretty heavy stack allocation,
I'm testing with node.js with express. Theoretically, If I run something very heavy calculation
I am unit testing mercurial integration and have a test class which currently creates
I'm trying to improve the automated testing in my application, but am unsure of
I was trying to put some heavy load on my Redis for testing purposes
Testing: return request.getCookies() == null; is not an appropriate way test. Is there another

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.