Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Threads In Java... WTF?

Featured Replies

I legit don't understand wtf is the point of them. This is the example code:

 

class Loader extends Thread {
    public void run() {
        System.out.println(“Hello”);
    }
}

class Program {
    public static void main(String[] args) {
        Loader load = new Loader();
        //load.setPriority(10);
        load.start();
    }
}

 

 

So what's the point of using Threads? Can somebody please explain the usefulness of this?

Are threads good because you can optimize the program and spilt the work between two processors?

Or maybe they're good because you can change priority and make certain calculations more important than others?

Edit: wtf is the runnable interface? I know its another way of creating threads but whats the point?

 

Please & Thank You

Edited by obasan

So you posed questions and then answered them for yourself...

Maybe you could hire me, do my job for me and still pay me.

You can implement runnable and still extend from another class.

Imagine if you have a webserver that only operates on 1 thread synchronously. It could only handle one request at a time. Lets say a user visits and another user visits 1 second after, it has to grab his data from the database, do whatever calculations etc, and resolve the first users request before being able to even recognize the second user has sent a request to the website. This is due to the only thread being blocked from the first request, so no other requests can be considered.

The most important thing to understand with threads is that they run concurrently. Imagine you have a program that has a GUI with a button in it. If the button is pressed and you'd execute some heavy calculation (or wait for something) in the same thread (the GUI is running on and being repainted in) ... the whole application would go unresponsive. By using another thread to do the calculation it will keep responsive. It's generally much better to work with Runnables instead of threads as it's much more flexible. Also look up ExecutorService to run them properly.

  • Author
On 4/12/2017 at 3:17 PM, Final said:

So you posed questions and then answered them for yourself...

Maybe you could hire me, do my job for me and still pay me.

lol'd. i might just do that ;)

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.