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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:05:21+00:00 2026-06-11T07:05:21+00:00

I have a thread that, when the current application closes, must start the main()

  • 0

I have a thread that, when the current application closes, must start the main() method of another class.
I included ClassName.main(someStringArray) in the run() of the thread but the method wasn’t called. What might have gone wrong?
The Thread I defined:

private class VideoCreator extends Thread{
        public VideoCreator(){
            pathToPass = savePath + "/" + "video.mov";
            passVect.add("-w");
            passVect.add("1280");
            passVect.add("-h");
            passVect.add("800");
            passVect.add("-f");
            passVect.add("25");
            passVect.add("-o");
            passVect.add(pathToPass);
        }
        @Override
        public void run(){
            try{
                jpegFiles = Files.newDirectoryStream(Paths.get(pathToPass).getParent(),"*.jpg");
                for(Path jpegFile : jpegFiles){
                    passVect.add(jpegFile.toString());
                }
            }catch(IOException e){

            }
            try{
                JpegImagesToMovie.main((String[])passVect.toArray());
            }catch(Exception e){
                System.out.println("Dammit Error!");
                e.printStackTrace();
            }
        }
        public void cleanUp(){

        }
        String pathToPass;
        Vector<String> passVect = new Vector<>(100,200);
        DirectoryStream<Path> jpegFiles;
    }
  • 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-06-11T07:05:22+00:00Added an answer on June 11, 2026 at 7:05 am

    Instead of

    (String[])passVect.toArray()
    

    you should write

    passVect.toArray(new String[passVect.size()])
    

    or (shorter but less performant)

    passVect.toArray(new String[0])
    

    The reason is that toArray() will always return an Object[] array, which you cannot convert to a String[] array even if all its members are strings. (The reverse, by the way, is possible: you can pass a String[] in places expecting Object[], which is used by various methods of the Arrays class. In fact, the thing returned from the toArray() method might have been a String[], even if in a standards-compliant implementation it is not. This is the reason why the compiler didn’t complain: it doesn’t know or care about the internals of the method, and judging from the return type, an explicit cast to an array of a subclass might be possible if the array was created as such.)

    The toArray(T[]) call returns an array of the required type, if you pass an array of that type as an argument. If the passed argument has the correct length, it will be used directly; otherwise a new array will be allocated. For this reason, allocating the correct length in the first place will avoid one allocation along the way.

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

Sidebar

Related Questions

I have a background thread that is sending data about the application's current status
* So I have a Thread that holds a sleep method and I think
In the application I'm developing, I have a thread that is running in a
I have a main thread that invokes a child thread function at different times
I have app that uses two threads: one thread for regular application work and
I have a thread that does the following: 1) Do some work 2) Wait
I have one thread that is receiving data over a socket like this: while
I have a thread that downloads some images from internet using different proxies. Sometimes
I have a thread that sends GPS coordinates to a database every six seconds
I currently have a thread that I created using CreateRemoteThread(). Everything works great. Upon

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.