• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 07:30
CEST 13:30
KST 20:30
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
Code S Season 1 - RO12 Group A: Rogue, Percival, Solar, Zoun13[ASL21] Ro8 Preview Pt1: Inheritors16[ASL21] Ro16 Preview Pt2: All Star10Team Liquid Map Contest #22 - The Finalists22[ASL21] Ro16 Preview Pt1: Fresh Flow9
Community News
RSL Revival: Season 5 - Qualifiers and Main Event8Code S Season 1 (2026) - RO12 Results02026 GSL Season 1 Qualifiers25Maestros of the Game 2 announced92026 GSL Tour plans announced15
StarCraft 2
General
Code S Season 1 - RO12 Group A: Rogue, Percival, Solar, Zoun Code S Season 1 (2026) - RO12 Results Team Liquid Map Contest #22 - The Finalists Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool MaNa leaves Team Liquid
Tourneys
RSL Revival: Season 5 - Qualifiers and Main Event GSL Code S Season 1 (2026) SC2 INu's Battles#15 <BO.9 2Matches> WardiTV Spring Cup SEL Masters #6 - Solar vs Classic (SC: Evo)
Strategy
Custom Maps
[D]RTS in all its shapes and glory <3 [A] Nemrods 1/4 players [M] (2) Frigid Storage
External Content
The PondCast: SC2 News & Results Mutation # 523 Firewall Mutation # 522 Flip My Base Mutation # 521 Memorable Boss
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ ASL21 General Discussion Why there arent any 256x256 pro maps? [BSL22] RO16 Group B - Saturday 21:00 CEST BW General Discussion
Tourneys
[Megathread] Daily Proleagues [ASL21] Ro8 Day 2 Escore Tournament StarCraft Season 2 [BSL22] RO16 Group Stage - 02 - 10 May
Strategy
Fighting Spirit mining rates Simple Questions, Simple Answers What's the deal with APM & what's its true value Any training maps people recommend?
Other Games
General Games
Stormgate/Frost Giant Megathread Dawn of War IV Nintendo Switch Thread Daigo vs Menard Best of 10 Diablo IV
Dota 2
The Story of Wings Gaming
League of Legends
G2 just beat GenG in First stand
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas TL Mafia Community Thread Five o'clock TL Mafia
Community
General
US Politics Mega-thread European Politico-economics QA Mega-thread Russo-Ukrainian War Thread 3D technology/software discussion Canadian Politics Mega-thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
[Manga] One Piece Anime Discussion Thread [Req][Books] Good Fantasy/SciFi books Movie Discussion!
Sports
2024 - 2026 Football Thread McBoner: A hockey love story Formula 1 Discussion
World Cup 2022
Tech Support
streaming software Strange computer issues (software) [G] How to Block Livestream Ads
TL Community
The Automated Ban List
Blogs
ramps on octagon
StaticNine
Sexual Health Of Gamers
TrAiDoS
Broowar part 2
qwaykee
Funny Nicknames
LUCKY_NOOB
ASL S21 English Commentary…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2142 users

The Big Programming Thread - Page 548

Forum Index > General Forum
Post a Reply
Prev 1 546 547 548 549 550 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
Manit0u
Profile Blog Joined August 2004
Poland17743 Posts
Last Edited: 2014-11-17 22:27:28
November 17 2014 22:24 GMT
#10941
On November 18 2014 00:09 BByte wrote:
Show nested quote +
On November 17 2014 21:25 goody153 wrote:
I was specifically tasked to convert 2 websites that was hardcoded into MVC coding style(or architecture or whatever the term i should use) so i did some googling and i ended up finding 3 PHP framework that apparently commonly used and i believe would help me on the task which are CakePHP, Laravel and CodeIgniter.

I won't ask which one is the best since they all probably have their own pros and cons. So my question would be which PHP framework between CakePHP, Laravel and CodeIgniter have you guys used or have been using ? or have you switched from one framework to another ? or which framework have you had a wonderful experience or have worked on you? which didn't ?


I haven't used any of the mentioned frameworks extensively, I use Symfony both at work and for some of my own projects. Based on what impressions I have of the three mentioned, I'd choose Laravel.

The best framework really depends on what you actually need to convert those sites. If they are rather simple, you may want to consider using a micro-framework. Even something simple will force you to use a proper MVC model and micro-frameworks can be a lot easier to learn. You certainly don't have to use or learn to use every component even if you pick a heavier option though.

When converting an existing site I'd especially consider support for different types of template and configuration files. If the sites are currently hardcoded, it's likely the view / template code is written in raw HTML + PHP. You may want to keep it that way and just separate the business logic. But if you also need to create some new templates a proper template engine can be useful. Mixing different types of templates may not be the cleanest solution, but in can mean a lot less work. Same goes for config files: Maybe you want to keep some of the old PHP or XML files, but want to use YAML for the new files. If the framework can seamlessly support different types of configuration, it's a little easier.


I'm also using Symfony (and now Kohana) and would also suggest Laravel. CodeIgniter is nice but it's rather dated and hasn't been developed for years so it might not adhere to the more modern approach and evolution of PHP itself. If you're new to the MVC pattern (that's what you call it) I'd suggest trying it out first in mini (formerly known simply as php-mvc) which is a micro-framework that let's you get the gist of it in 30 minutes or so. It's pretty bare bones but that's good, you'll learn how things work and it'll be much easier for you to jump to full-stack frameworks like Laravel or Symphony which offer a much higher level of abstraction. Because they offer all those abstraction layers you might find yourself doing stuff without actually knowing or fully understanding what's going on. I don't know about mini but php-mvc also had an "advanced" fork where you got SASS support and Twig templating engine.

I used to really hate Symfony, but after trying out some other frameworks I'm actually missing it in my new job (except for Sonata and CMF parts of it, I still despise them).
Time is precious. Waste it wisely.
Azerbaijan
Profile Blog Joined January 2010
United States660 Posts
November 17 2014 23:38 GMT
#10942
I can't get JSTL into my jsp. I am using this include statement which seems to work for everyone else on the internet.

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

I am using maven and have the javaee-web-api dependency in my project and on my build path. I can see the JSTL packages inside the jar but my include statement just won't find them and I do not know why. It does work if I get the JSTL dependency specifically but that just makes wonder why they bundled the entire web api into one package if I can't actually use the stuff inside of it. I am sure I am missing something obvious ><
goody153
Profile Blog Joined April 2013
44272 Posts
November 18 2014 01:16 GMT
#10943
On November 18 2014 07:24 Manit0u wrote:
Show nested quote +
On November 18 2014 00:09 BByte wrote:
On November 17 2014 21:25 goody153 wrote:
I was specifically tasked to convert 2 websites that was hardcoded into MVC coding style(or architecture or whatever the term i should use) so i did some googling and i ended up finding 3 PHP framework that apparently commonly used and i believe would help me on the task which are CakePHP, Laravel and CodeIgniter.

I won't ask which one is the best since they all probably have their own pros and cons. So my question would be which PHP framework between CakePHP, Laravel and CodeIgniter have you guys used or have been using ? or have you switched from one framework to another ? or which framework have you had a wonderful experience or have worked on you? which didn't ?


I haven't used any of the mentioned frameworks extensively, I use Symfony both at work and for some of my own projects. Based on what impressions I have of the three mentioned, I'd choose Laravel.

The best framework really depends on what you actually need to convert those sites. If they are rather simple, you may want to consider using a micro-framework. Even something simple will force you to use a proper MVC model and micro-frameworks can be a lot easier to learn. You certainly don't have to use or learn to use every component even if you pick a heavier option though.

When converting an existing site I'd especially consider support for different types of template and configuration files. If the sites are currently hardcoded, it's likely the view / template code is written in raw HTML + PHP. You may want to keep it that way and just separate the business logic. But if you also need to create some new templates a proper template engine can be useful. Mixing different types of templates may not be the cleanest solution, but in can mean a lot less work. Same goes for config files: Maybe you want to keep some of the old PHP or XML files, but want to use YAML for the new files. If the framework can seamlessly support different types of configuration, it's a little easier.


I'm also using Symfony (and now Kohana) and would also suggest Laravel. CodeIgniter is nice but it's rather dated and hasn't been developed for years so it might not adhere to the more modern approach and evolution of PHP itself. If you're new to the MVC pattern (that's what you call it) I'd suggest trying it out first in mini (formerly known simply as php-mvc) which is a micro-framework that let's you get the gist of it in 30 minutes or so. It's pretty bare bones but that's good, you'll learn how things work and it'll be much easier for you to jump to full-stack frameworks like Laravel or Symphony which offer a much higher level of abstraction. Because they offer all those abstraction layers you might find yourself doing stuff without actually knowing or fully understanding what's going on. I don't know about mini but php-mvc also had an "advanced" fork where you got SASS support and Twig templating engine.

I used to really hate Symfony, but after trying out some other frameworks I'm actually missing it in my new job (except for Sonata and CMF parts of it, I still despise them).

Ok i'll try this php-mini first. Thanks .

On November 18 2014 00:09 BByte wrote:
Show nested quote +
On November 17 2014 21:25 goody153 wrote:
I was specifically tasked to convert 2 websites that was hardcoded into MVC coding style(or architecture or whatever the term i should use) so i did some googling and i ended up finding 3 PHP framework that apparently commonly used and i believe would help me on the task which are CakePHP, Laravel and CodeIgniter.

I won't ask which one is the best since they all probably have their own pros and cons. So my question would be which PHP framework between CakePHP, Laravel and CodeIgniter have you guys used or have been using ? or have you switched from one framework to another ? or which framework have you had a wonderful experience or have worked on you? which didn't ?


I haven't used any of the mentioned frameworks extensively, I use Symfony both at work and for some of my own projects. Based on what impressions I have of the three mentioned, I'd choose Laravel.

The best framework really depends on what you actually need to convert those sites. If they are rather simple, you may want to consider using a micro-framework. Even something simple will force you to use a proper MVC model and micro-frameworks can be a lot easier to learn. You certainly don't have to use or learn to use every component even if you pick a heavier option though.

When converting an existing site I'd especially consider support for different types of template and configuration files. If the sites are currently hardcoded, it's likely the view / template code is written in raw HTML + PHP. You may want to keep it that way and just separate the business logic. But if you also need to create some new templates a proper template engine can be useful. Mixing different types of templates may not be the cleanest solution, but in can mean a lot less work. Same goes for config files: Maybe you want to keep some of the old PHP or XML files, but want to use YAML for the new files. If the framework can seamlessly support different types of configuration, it's a little easier.


What i'm trying to convert is raw HTML + PHP coded and i would like to use majority of the codes from it since i don't want to recreate most of the functions.



Alright people has also been saying Symphony or Laravel so i'll try both and get the feel which i would like to use. And i won't be using codeigniter since people said that easier but there is no support behind it anymore.

Thank guys.
this is a quote
Manit0u
Profile Blog Joined August 2004
Poland17743 Posts
November 20 2014 02:12 GMT
#10944
Why are so many developers using MacBooks? Are they that good or is it just a trendy thing to do? I'm asking because I need a new laptop for work and am seriously considering giving it a shot even though I despise Apple products...
Time is precious. Waste it wisely.
ZenithM
Profile Joined February 2011
France15952 Posts
Last Edited: 2014-11-20 03:23:59
November 20 2014 02:28 GMT
#10945
My guess is that MacBooks are premium devices (good keyboard and touchpad, good screen, robust, good battery life etc..) and Mac OS X is POSIX compliant, which makes macbooks very usable in a Unix development setting. There are also a few productivity goodies on macbooks, like fancy multitouch touchpad gestures and such.

But they could probably do the same shit they do with a computer half as cheap. Apple's marketing and brand loyalty is just that good.
phar
Profile Joined August 2011
United States1080 Posts
November 20 2014 02:29 GMT
#10946
Solid product, and usually someone else (your company) is paying.
Who after all is today speaking about the destruction of the Armenians?
berated-
Profile Blog Joined February 2007
United States1134 Posts
November 20 2014 02:30 GMT
#10947
On November 18 2014 08:38 Azerbaijan wrote:
I can't get JSTL into my jsp. I am using this include statement which seems to work for everyone else on the internet.

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

I am using maven and have the javaee-web-api dependency in my project and on my build path. I can see the JSTL packages inside the jar but my include statement just won't find them and I do not know why. It does work if I get the JSTL dependency specifically but that just makes wonder why they bundled the entire web api into one package if I can't actually use the stuff inside of it. I am sure I am missing something obvious ><


What container are you deploying to? How are you declaring your dependency for the javaee-web-api and what version?
Manit0u
Profile Blog Joined August 2004
Poland17743 Posts
November 20 2014 02:41 GMT
#10948
On November 20 2014 11:29 phar wrote:
Solid product, and usually someone else (your company) is paying.


The thing is, I have to buy it myself for my personal use. Just found out I can get just as good MSI laptop for half the price.
Time is precious. Waste it wisely.
WolfintheSheep
Profile Joined June 2011
Canada14127 Posts
November 20 2014 03:02 GMT
#10949
On November 20 2014 11:41 Manit0u wrote:
Show nested quote +
On November 20 2014 11:29 phar wrote:
Solid product, and usually someone else (your company) is paying.


The thing is, I have to buy it myself for my personal use. Just found out I can get just as good MSI laptop for half the price.

MSI and ASUS make good laptops for a good price, if you want something with a bit more power (especially graphics-wise).

There's a lot more options when it comes to extremely barebones machines.
Average means I'm better than half of you.
teamamerica
Profile Blog Joined July 2010
United States958 Posts
November 20 2014 07:40 GMT
#10950
Hey guys, I was wondering how the elasticsearch option "mlockall" to prevent JVM from using heap memory is actually implemented.

Also was wondering - at work they have some elasticsearch nodes (I don't work on them, I just do monitoring T_T) but I was looking into the boxes for some issue and was seeing few things I had question on

1) JVM were configured with mlockall but were still using swap (these are running on physical servers). Shouldn't they not be?
2) Servers have 100gb RAM and were at maybe 80gb usage, was seeing there was still some swap usage. Why would anything use swap space before ram gets filled (vm.swapiness set to 60 if thats reason)


RIP GOMTV. RIP PROLEAGUE.
Manit0u
Profile Blog Joined August 2004
Poland17743 Posts
November 20 2014 08:40 GMT
#10951
On November 20 2014 16:40 teamamerica wrote:
Hey guys, I was wondering how the elasticsearch option "mlockall" to prevent JVM from using heap memory is actually implemented.

Also was wondering - at work they have some elasticsearch nodes (I don't work on them, I just do monitoring T_T) but I was looking into the boxes for some issue and was seeing few things I had question on

1) JVM were configured with mlockall but were still using swap (these are running on physical servers). Shouldn't they not be?
2) Servers have 100gb RAM and were at maybe 80gb usage, was seeing there was still some swap usage. Why would anything use swap space before ram gets filled (vm.swapiness set to 60 if thats reason)




Ad. 2:

Swapping is necessary for two important reasons. First, when the system requires more memory than is physically available, the kernel swaps out less used pages and gives memory to the current application (process) that needs the memory immediately. Second, a significant number of the pages used by an application during its startup phase may only be used for initialization and then never used again. The system can swap out those pages and free the memory for other applications or even for the disk cache.

Source: http://www.linux.com/news/software/applications/8208-all-about-linux-swap-space
Time is precious. Waste it wisely.
Manit0u
Profile Blog Joined August 2004
Poland17743 Posts
November 20 2014 14:56 GMT
#10952


Good times...
Time is precious. Waste it wisely.
raNazUra
Profile Joined December 2012
United States10 Posts
November 20 2014 21:18 GMT
#10953
I have a code question. The long and the short of it is that I don't fully understand threads in Java, or perhaps simply their interaction with applets. Here's a simplified version of the problem I'm having:

+ Show Spoiler +
import java.applet.Applet;
import java.awt.Button;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class TestApplet extends Applet {
public Button spawnThread;

private class ButtonPresser implements Runnable {

public Button endThread;
public TestApplet parent;
public Object notifier = new Object();

public ButtonPresser(TestApplet parent){
this.parent = parent;
}

@Override
public void run() {
synchronized(notifier){
endThread = new Button("End Thread");
endThread.setBounds(0,100,100,20);
endThread.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
synchronized(notifier) {
notifier.notify();
}
}
});
parent.add(endThread);

try {
notifier.wait();
System.out.println("Thread is done!");
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
}
}

public void init() {
final TestApplet thisApp = this;
spawnThread = new Button("Spawn Thread");
spawnThread.setBounds(0,0,100,20);
spawnThread.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Thread t = new Thread(new ButtonPresser(thisApp));
t.run();
try {
t.join();
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
});
add(spawnThread);
}
}


What I am attempting to do is spawn a thread that adds a button to an applet that will kill said thread. In order to do this, I am creating a button whose listener tells it to notify the object on which the thread's run method is currently waiting, thereby allowing the run() to complete and the thread to terminate. However, when I run this and click on the Spawn Thread button, the End Thread button is added, and then the applet completely locks up (accepts no clicks and can't be closed, have to kill the process). Can anyone explain to me why this is? I'm sure I'm doing something fundamentally stupid but am not sure what it is.

Also, I know no one uses applets anymore, that's what I see on every Stack Overflow question I read, but my guess is that this problem is not inherent to applets, but rather to my understanding. Also it seems I should be trying to use the java.util.concurrent library, but I'd like to know why this doesn't work before moving there.
Speak the truth, even if your voice shakes
berated-
Profile Blog Joined February 2007
United States1134 Posts
November 21 2014 01:07 GMT
#10954
On November 21 2014 06:18 raNazUra wrote:
I have a code question. The long and the short of it is that I don't fully understand threads in Java, or perhaps simply their interaction with applets. Here's a simplified version of the problem I'm having:

+ Show Spoiler +
import java.applet.Applet;
import java.awt.Button;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class TestApplet extends Applet {
public Button spawnThread;

private class ButtonPresser implements Runnable {

public Button endThread;
public TestApplet parent;
public Object notifier = new Object();

public ButtonPresser(TestApplet parent){
this.parent = parent;
}

@Override
public void run() {
synchronized(notifier){
endThread = new Button("End Thread");
endThread.setBounds(0,100,100,20);
endThread.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
synchronized(notifier) {
notifier.notify();
}
}
});
parent.add(endThread);

try {
notifier.wait();
System.out.println("Thread is done!");
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
}
}

public void init() {
final TestApplet thisApp = this;
spawnThread = new Button("Spawn Thread");
spawnThread.setBounds(0,0,100,20);
spawnThread.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Thread t = new Thread(new ButtonPresser(thisApp));
t.run();
try {
t.join();
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
});
add(spawnThread);
}
}


What I am attempting to do is spawn a thread that adds a button to an applet that will kill said thread. In order to do this, I am creating a button whose listener tells it to notify the object on which the thread's run method is currently waiting, thereby allowing the run() to complete and the thread to terminate. However, when I run this and click on the Spawn Thread button, the End Thread button is added, and then the applet completely locks up (accepts no clicks and can't be closed, have to kill the process). Can anyone explain to me why this is? I'm sure I'm doing something fundamentally stupid but am not sure what it is.

Also, I know no one uses applets anymore, that's what I see on every Stack Overflow question I read, but my guess is that this problem is not inherent to applets, but rather to my understanding. Also it seems I should be trying to use the java.util.concurrent library, but I'd like to know why this doesn't work before moving there.


Thread.join

When you call thread.join() from the main thread, it is now going to wait on the other thread to finish before it moves on.

You've created a deadlock. Thread a creates thread b. Thread b must be stopped by an action on thread a. However, thread a is currently waiting for thread b to finish before it can respond. Everyone loses.

Also, you shouldn't be calling thread.run(). You should call thread.start().

Starting a thread
berated-
Profile Blog Joined February 2007
United States1134 Posts
November 21 2014 02:34 GMT
#10955
On November 20 2014 16:40 teamamerica wrote:
Hey guys, I was wondering how the elasticsearch option "mlockall" to prevent JVM from using heap memory is actually implemented.

Also was wondering - at work they have some elasticsearch nodes (I don't work on them, I just do monitoring T_T) but I was looking into the boxes for some issue and was seeing few things I had question on

1) JVM were configured with mlockall but were still using swap (these are running on physical servers). Shouldn't they not be?
2) Servers have 100gb RAM and were at maybe 80gb usage, was seeing there was still some swap usage. Why would anything use swap space before ram gets filled (vm.swapiness set to 60 if thats reason)




5 minutes of googling (so if its wrong, sorry..) shows that mlockall with the jvm is used through the lucid works java agent.

Lucid Works Java Agent

Are you guys following their recommended settings?
raNazUra
Profile Joined December 2012
United States10 Posts
November 21 2014 03:15 GMT
#10956
On November 21 2014 10:07 berated- wrote:
Show nested quote +
On November 21 2014 06:18 raNazUra wrote:
I have a code question. The long and the short of it is that I don't fully understand threads in Java, or perhaps simply their interaction with applets. Here's a simplified version of the problem I'm having:

+ Show Spoiler +
import java.applet.Applet;
import java.awt.Button;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class TestApplet extends Applet {
public Button spawnThread;

private class ButtonPresser implements Runnable {

public Button endThread;
public TestApplet parent;
public Object notifier = new Object();

public ButtonPresser(TestApplet parent){
this.parent = parent;
}

@Override
public void run() {
synchronized(notifier){
endThread = new Button("End Thread");
endThread.setBounds(0,100,100,20);
endThread.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
synchronized(notifier) {
notifier.notify();
}
}
});
parent.add(endThread);

try {
notifier.wait();
System.out.println("Thread is done!");
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
}
}

public void init() {
final TestApplet thisApp = this;
spawnThread = new Button("Spawn Thread");
spawnThread.setBounds(0,0,100,20);
spawnThread.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Thread t = new Thread(new ButtonPresser(thisApp));
t.run();
try {
t.join();
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
});
add(spawnThread);
}
}


What I am attempting to do is spawn a thread that adds a button to an applet that will kill said thread. In order to do this, I am creating a button whose listener tells it to notify the object on which the thread's run method is currently waiting, thereby allowing the run() to complete and the thread to terminate. However, when I run this and click on the Spawn Thread button, the End Thread button is added, and then the applet completely locks up (accepts no clicks and can't be closed, have to kill the process). Can anyone explain to me why this is? I'm sure I'm doing something fundamentally stupid but am not sure what it is.

Also, I know no one uses applets anymore, that's what I see on every Stack Overflow question I read, but my guess is that this problem is not inherent to applets, but rather to my understanding. Also it seems I should be trying to use the java.util.concurrent library, but I'd like to know why this doesn't work before moving there.


Thread.join

When you call thread.join() from the main thread, it is now going to wait on the other thread to finish before it moves on.

You've created a deadlock. Thread a creates thread b. Thread b must be stopped by an action on thread a. However, thread a is currently waiting for thread b to finish before it can respond. Everyone loses.

Also, you shouldn't be calling thread.run(). You should call thread.start().

Starting a thread


Yes, the join() functionality is what I wanted, but I think I know where the problem is now. I had been forgetting to think about which thread deals with the actual ClickEvent, which presumably would be the main thread for applets. So then the main thread is waiting on the created thread to finish and can't jump out to execute ActionListener code for button presses? Time to go test this.
Speak the truth, even if your voice shakes
berated-
Profile Blog Joined February 2007
United States1134 Posts
November 21 2014 03:27 GMT
#10957
On November 21 2014 12:15 raNazUra wrote:
Show nested quote +
On November 21 2014 10:07 berated- wrote:
On November 21 2014 06:18 raNazUra wrote:
I have a code question. The long and the short of it is that I don't fully understand threads in Java, or perhaps simply their interaction with applets. Here's a simplified version of the problem I'm having:

+ Show Spoiler +
import java.applet.Applet;
import java.awt.Button;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class TestApplet extends Applet {
public Button spawnThread;

private class ButtonPresser implements Runnable {

public Button endThread;
public TestApplet parent;
public Object notifier = new Object();

public ButtonPresser(TestApplet parent){
this.parent = parent;
}

@Override
public void run() {
synchronized(notifier){
endThread = new Button("End Thread");
endThread.setBounds(0,100,100,20);
endThread.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
synchronized(notifier) {
notifier.notify();
}
}
});
parent.add(endThread);

try {
notifier.wait();
System.out.println("Thread is done!");
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
}
}

public void init() {
final TestApplet thisApp = this;
spawnThread = new Button("Spawn Thread");
spawnThread.setBounds(0,0,100,20);
spawnThread.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Thread t = new Thread(new ButtonPresser(thisApp));
t.run();
try {
t.join();
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
});
add(spawnThread);
}
}


What I am attempting to do is spawn a thread that adds a button to an applet that will kill said thread. In order to do this, I am creating a button whose listener tells it to notify the object on which the thread's run method is currently waiting, thereby allowing the run() to complete and the thread to terminate. However, when I run this and click on the Spawn Thread button, the End Thread button is added, and then the applet completely locks up (accepts no clicks and can't be closed, have to kill the process). Can anyone explain to me why this is? I'm sure I'm doing something fundamentally stupid but am not sure what it is.

Also, I know no one uses applets anymore, that's what I see on every Stack Overflow question I read, but my guess is that this problem is not inherent to applets, but rather to my understanding. Also it seems I should be trying to use the java.util.concurrent library, but I'd like to know why this doesn't work before moving there.


Thread.join

When you call thread.join() from the main thread, it is now going to wait on the other thread to finish before it moves on.

You've created a deadlock. Thread a creates thread b. Thread b must be stopped by an action on thread a. However, thread a is currently waiting for thread b to finish before it can respond. Everyone loses.

Also, you shouldn't be calling thread.run(). You should call thread.start().

Starting a thread


Yes, the join() functionality is what I wanted, but I think I know where the problem is now. I had been forgetting to think about which thread deals with the actual ClickEvent, which presumably would be the main thread for applets. So then the main thread is waiting on the created thread to finish and can't jump out to execute ActionListener code for button presses? Time to go test this.


Why do you want join? You shouldn't care on the thread that creates the second thread what the second thread is doing? You just want it running, yes? Join explicitly takes away the whole value that you created by offloading to another thread by rejoining them together.
phar
Profile Joined August 2011
United States1080 Posts
November 21 2014 05:34 GMT
#10958
On November 20 2014 11:41 Manit0u wrote:
Show nested quote +
On November 20 2014 11:29 phar wrote:
Solid product, and usually someone else (your company) is paying.


The thing is, I have to buy it myself for my personal use. Just found out I can get just as good MSI laptop for half the price.

Yea I personally wouldn't spend the markup out of my own pocket. But then again, if I had no company phone and had to get my own phone, I'd be eyeing the $100 moto e.
Who after all is today speaking about the destruction of the Armenians?
raNazUra
Profile Joined December 2012
United States10 Posts
November 21 2014 06:03 GMT
#10959
On November 21 2014 12:27 berated- wrote:
Show nested quote +
On November 21 2014 12:15 raNazUra wrote:
On November 21 2014 10:07 berated- wrote:
On November 21 2014 06:18 raNazUra wrote:
I have a code question. The long and the short of it is that I don't fully understand threads in Java, or perhaps simply their interaction with applets. Here's a simplified version of the problem I'm having:

+ Show Spoiler +
import java.applet.Applet;
import java.awt.Button;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class TestApplet extends Applet {
public Button spawnThread;

private class ButtonPresser implements Runnable {

public Button endThread;
public TestApplet parent;
public Object notifier = new Object();

public ButtonPresser(TestApplet parent){
this.parent = parent;
}

@Override
public void run() {
synchronized(notifier){
endThread = new Button("End Thread");
endThread.setBounds(0,100,100,20);
endThread.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
synchronized(notifier) {
notifier.notify();
}
}
});
parent.add(endThread);

try {
notifier.wait();
System.out.println("Thread is done!");
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
}
}

public void init() {
final TestApplet thisApp = this;
spawnThread = new Button("Spawn Thread");
spawnThread.setBounds(0,0,100,20);
spawnThread.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Thread t = new Thread(new ButtonPresser(thisApp));
t.run();
try {
t.join();
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
});
add(spawnThread);
}
}


What I am attempting to do is spawn a thread that adds a button to an applet that will kill said thread. In order to do this, I am creating a button whose listener tells it to notify the object on which the thread's run method is currently waiting, thereby allowing the run() to complete and the thread to terminate. However, when I run this and click on the Spawn Thread button, the End Thread button is added, and then the applet completely locks up (accepts no clicks and can't be closed, have to kill the process). Can anyone explain to me why this is? I'm sure I'm doing something fundamentally stupid but am not sure what it is.

Also, I know no one uses applets anymore, that's what I see on every Stack Overflow question I read, but my guess is that this problem is not inherent to applets, but rather to my understanding. Also it seems I should be trying to use the java.util.concurrent library, but I'd like to know why this doesn't work before moving there.


Thread.join

When you call thread.join() from the main thread, it is now going to wait on the other thread to finish before it moves on.

You've created a deadlock. Thread a creates thread b. Thread b must be stopped by an action on thread a. However, thread a is currently waiting for thread b to finish before it can respond. Everyone loses.

Also, you shouldn't be calling thread.run(). You should call thread.start().

Starting a thread


Yes, the join() functionality is what I wanted, but I think I know where the problem is now. I had been forgetting to think about which thread deals with the actual ClickEvent, which presumably would be the main thread for applets. So then the main thread is waiting on the created thread to finish and can't jump out to execute ActionListener code for button presses? Time to go test this.


Why do you want join? You shouldn't care on the thread that creates the second thread what the second thread is doing? You just want it running, yes? Join explicitly takes away the whole value that you created by offloading to another thread by rejoining them together.


Ok, so I'll just give a high-level picture of what I was hoping for. There's probably a proper paradigm for doing what I want to do, so that would also be welcome advice. Here's what I want:

main:
Run some code
Create a couple buttons, one of which is "Done tinkering"
Run some more code based on previous button presses (including possible branches)
More buttons, including "Done" button,
etc.

So my goal was to spawn a new thread for all the buttons, which will terminate when I'm done messing with them, at which point the main thread continues on. Originally I was being even terribler, and passing the future code to be executed around inside Buttons, which would get sent an event when the "Done" button was pressed.

Basically, when "Done" is pressed, I would greatly prefer to back out one level to whatever set it up, rather than pass the future code into the "Done" creation to be executed on the press.
Speak the truth, even if your voice shakes
berated-
Profile Blog Joined February 2007
United States1134 Posts
November 21 2014 10:49 GMT
#10960
On November 21 2014 15:03 raNazUra wrote:
Show nested quote +
On November 21 2014 12:27 berated- wrote:
On November 21 2014 12:15 raNazUra wrote:
On November 21 2014 10:07 berated- wrote:
On November 21 2014 06:18 raNazUra wrote:
I have a code question. The long and the short of it is that I don't fully understand threads in Java, or perhaps simply their interaction with applets. Here's a simplified version of the problem I'm having:

+ Show Spoiler +
import java.applet.Applet;
import java.awt.Button;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class TestApplet extends Applet {
public Button spawnThread;

private class ButtonPresser implements Runnable {

public Button endThread;
public TestApplet parent;
public Object notifier = new Object();

public ButtonPresser(TestApplet parent){
this.parent = parent;
}

@Override
public void run() {
synchronized(notifier){
endThread = new Button("End Thread");
endThread.setBounds(0,100,100,20);
endThread.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
synchronized(notifier) {
notifier.notify();
}
}
});
parent.add(endThread);

try {
notifier.wait();
System.out.println("Thread is done!");
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
}
}

public void init() {
final TestApplet thisApp = this;
spawnThread = new Button("Spawn Thread");
spawnThread.setBounds(0,0,100,20);
spawnThread.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Thread t = new Thread(new ButtonPresser(thisApp));
t.run();
try {
t.join();
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
});
add(spawnThread);
}
}


What I am attempting to do is spawn a thread that adds a button to an applet that will kill said thread. In order to do this, I am creating a button whose listener tells it to notify the object on which the thread's run method is currently waiting, thereby allowing the run() to complete and the thread to terminate. However, when I run this and click on the Spawn Thread button, the End Thread button is added, and then the applet completely locks up (accepts no clicks and can't be closed, have to kill the process). Can anyone explain to me why this is? I'm sure I'm doing something fundamentally stupid but am not sure what it is.

Also, I know no one uses applets anymore, that's what I see on every Stack Overflow question I read, but my guess is that this problem is not inherent to applets, but rather to my understanding. Also it seems I should be trying to use the java.util.concurrent library, but I'd like to know why this doesn't work before moving there.


Thread.join

When you call thread.join() from the main thread, it is now going to wait on the other thread to finish before it moves on.

You've created a deadlock. Thread a creates thread b. Thread b must be stopped by an action on thread a. However, thread a is currently waiting for thread b to finish before it can respond. Everyone loses.

Also, you shouldn't be calling thread.run(). You should call thread.start().

Starting a thread


Yes, the join() functionality is what I wanted, but I think I know where the problem is now. I had been forgetting to think about which thread deals with the actual ClickEvent, which presumably would be the main thread for applets. So then the main thread is waiting on the created thread to finish and can't jump out to execute ActionListener code for button presses? Time to go test this.


Why do you want join? You shouldn't care on the thread that creates the second thread what the second thread is doing? You just want it running, yes? Join explicitly takes away the whole value that you created by offloading to another thread by rejoining them together.


Ok, so I'll just give a high-level picture of what I was hoping for. There's probably a proper paradigm for doing what I want to do, so that would also be welcome advice. Here's what I want:

main:
Run some code
Create a couple buttons, one of which is "Done tinkering"
Run some more code based on previous button presses (including possible branches)
More buttons, including "Done" button,
etc.

So my goal was to spawn a new thread for all the buttons, which will terminate when I'm done messing with them, at which point the main thread continues on. Originally I was being even terribler, and passing the future code to be executed around inside Buttons, which would get sent an event when the "Done" button was pressed.

Basically, when "Done" is pressed, I would greatly prefer to back out one level to whatever set it up, rather than pass the future code into the "Done" creation to be executed on the press.


Thanks for the explanation and high level view, it makes things easier than just looking at a block of code. I'm by no means an applet expert, but, I'm going to try to restate what I believe you are trying to accomplish and the describe the approach I would take.

You want to create an applet with action buttons on it, we'll call them A, B, and C for short. When you click any of the buttons, you will add a Stop (A|B|C) button, as well as start the Action (A|B|C). Clicking the stop button will terminate the action.

If this is the case, I would have some sort of listener on buttons A, B, C like you do now. However, from looking at your code, I would change where the logic runs. For me, it makes most sense for the original button listener to
- create the thread
- create the stop button
- create the stop button listener with a reference to the created thread
- start the thread
- add the button to the screen

Since the newly created button listener has reference to the newly created thread, the only thing you'll have to do click is to stop the thread. No reason for joins anywhere. The reason I would do it like this is from a separation of concerns part. The thread should be responsible for doing whatever background logic you want to be happening is. The main applet and button listeners are responsible for the coordination of the creation of threads and buttons.
Prev 1 546 547 548 549 550 1032 Next
Please log in or register to reply.
Live Events Refresh
RSL Revival
10:00
Season 5: Group B
Solar vs herOLIVE!
TriGGeR vs NightMare
Tasteless664
IntoTheiNu 390
Ryung 329
IndyStarCraft 236
Rex108
3DClanTV 100
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Tasteless 664
Ryung 329
IndyStarCraft 236
Rex 108
StarCraft: Brood War
Britney 51505
Horang2 1548
Shuttle 606
Rush 365
Soma 365
Hyuk 351
EffOrt 326
firebathero 204
Last 197
Leta 187
[ Show more ]
ggaemo 165
ToSsGirL 107
Pusan 86
Hm[arnc] 74
PianO 71
Sharp 62
[sc1f]eonzerg 49
Sacsri 40
NaDa 30
Sea.KH 24
JulyZerg 19
IntoTheRainbow 19
Barracks 17
yabsab 15
Shine 14
Noble 12
GoRush 11
Dota 2
XaKoH 796
XcaliburYe284
monkeys_forever192
Counter-Strike
zeus1345
edward111
Other Games
singsing2296
B2W.Neo1378
Liquid`RaSZi714
DeMusliM339
TKL 131
Livibee90
ArmadaUGS53
MindelVK20
Organizations
Other Games
BasetradeTV600
Dota 2
PGL Dota 2 - Main Stream59
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 12 non-featured ]
StarCraft 2
• LUISG 2
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Jankos1693
Upcoming Events
uThermal 2v2 Circuit
2h 30m
BSL
7h 30m
IPSL
7h 30m
eOnzErG vs TBD
G5 vs Nesh
Patches Events
12h 30m
Replay Cast
21h 30m
Wardi Open
22h 30m
Afreeca Starleague
22h 30m
Jaedong vs Light
Monday Night Weeklies
1d 4h
Replay Cast
1d 12h
Sparkling Tuna Cup
1d 22h
[ Show More ]
Afreeca Starleague
1d 22h
Snow vs Flash
WardiTV Invitational
1d 23h
GSL
2 days
Classic vs Cure
Maru vs Rogue
GSL
3 days
SHIN vs Zoun
ByuN vs herO
OSC
3 days
OSC
4 days
Replay Cast
4 days
Escore
4 days
The PondCast
4 days
WardiTV Invitational
4 days
Replay Cast
5 days
CranKy Ducklings
5 days
RSL Revival
5 days
SHIN vs Bunny
ByuN vs Shameless
WardiTV Invitational
5 days
BSL
6 days
Replay Cast
6 days
Sparkling Tuna Cup
6 days
RSL Revival
6 days
Cure vs Zoun
Clem vs Lambo
WardiTV Invitational
6 days
Liquipedia Results

Completed

Escore Tournament S2: W5
WardiTV TLMC #16
Nations Cup 2026

Ongoing

BSL Season 22
ASL Season 21
CSL 2026 SPRING (S20)
IPSL Spring 2026
KCM Race Survival 2026 Season 2
KK 2v2 League Season 1
Acropolis #4
SCTL 2026 Spring
RSL Revival: Season 5
2026 GSL S1
BLAST Rivals Spring 2026
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026

Upcoming

Escore Tournament S2: W6
BSL 22 Non-Korean Championship
Escore Tournament S2: W7
Escore Tournament S2: W8
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
Maestros of the Game 2
2026 GSL S2
Stake Ranked Episode 3
XSE Pro League 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
IEM Atlanta 2026
Asian Champions League 2026
PGL Astana 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.